diff --git a/.ruby-version b/.ruby-version index dd44cb3..d538d61 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.0.0-p353 \ No newline at end of file +ruby-2.2.0 \ No newline at end of file diff --git a/Gemfile b/Gemfile index 04b0378..272d427 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,13 @@ source 'https://rubygems.org' gem 'rake' -gem "motion-cocoapods", "~> 1.4.0" -gem "motion-sparkle", "~> 0.0.3", :git => 'git@github.com:whomwah/motion-sparkle.git' -gem "bubble-wrap", "~> 1.4.0" -gem 'sugarcube', "~> 1.3.7", :require => [ +gem "motion-cocoapods" +gem 'afmotion' +gem "motion-sparkle" +gem "bubble-wrap" +gem 'sugarcube', :require => [ 'sugarcube-attributedstring', ] -gem "ib", "~> 0.4.3" +gem "ib" #gem "kyan_jukebox_websocket_lib", :path => "/Users/duncan/_dev/kyan/gems/kyan_jukebox_websocket_lib" gem "kyan_jukebox", :git => 'git@github.com:kyan/kyan_jukebox_websocket_lib.git' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 24b1318..9afb928 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,70 +4,85 @@ GIT specs: kyan_jukebox (0.2.0) -GIT - remote: git@github.com:whomwah/motion-sparkle.git - revision: bc1a604dc58b51fef2c099a6c4950e7a9a53d414 - specs: - motion-sparkle (0.0.3) - GEM remote: https://rubygems.org/ specs: - activesupport (3.2.16) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) - bubble-wrap (1.4.0) - claide (0.4.0) - cocoapods (0.29.0) - activesupport (>= 3.2.15, < 4) - claide (~> 0.4.0) - cocoapods-core (= 0.29.0) - cocoapods-downloader (~> 0.3.0) - cocoapods-try-release-fix (~> 0.1.1) + activesupport (4.2.0) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + afmotion (2.5) + motion-cocoapods (>= 1.4.1) + motion-require (>= 0.1) + bubble-wrap (1.7.1) + bubble-wrap-http (= 1.7.1) + bubble-wrap-http (1.7.1) + claide (0.7.0) + cocoapods (0.35.0) + activesupport (>= 3.2.15) + claide (~> 0.7.0) + cocoapods-core (= 0.35.0) + cocoapods-downloader (~> 0.8.0) + cocoapods-plugins (~> 0.3.1) + cocoapods-trunk (~> 0.4.1) + cocoapods-try (~> 0.4.2) colored (~> 1.2) escape (~> 0.0.4) - json_pure (~> 1.8) - nap (~> 0.5) + molinillo (~> 0.1.2) + nap (~> 0.8) open4 (~> 1.3) - xcodeproj (~> 0.14.1) - cocoapods-core (0.29.0) - activesupport (>= 3.2.15, < 4) + xcodeproj (~> 0.20.2) + cocoapods-core (0.35.0) + activesupport (>= 3.2.15) fuzzy_match (~> 2.0.4) - json_pure (~> 1.8) - nap (~> 0.5) - cocoapods-downloader (0.3.0) - cocoapods-try-release-fix (0.1.1) + nap (~> 0.8.0) + cocoapods-downloader (0.8.1) + cocoapods-plugins (0.3.2) + nap + cocoapods-trunk (0.4.1) + nap (>= 0.8) + netrc (= 0.7.8) + cocoapods-try (0.4.3) colored (1.2) escape (0.0.4) fuzzy_match (2.0.4) - i18n (0.6.9) - ib (0.4.3) - thor (>= 0.15.4) - tilt (>= 1.4.1) - xcodeproj (>= 0.11.1) - json_pure (1.8.1) - motion-cocoapods (1.4.0) - cocoapods (>= 0.26.2) - multi_json (1.8.4) - nap (0.6.0) - open4 (1.3.0) - rake (10.1.1) - sugarcube (1.3.11) - thor (0.18.1) - tilt (2.0.0) - xcodeproj (0.14.1) - activesupport (~> 3.0) + i18n (0.7.0) + ib (0.7.2) + thor (~> 0.15.4) + tilt (~> 1.4.1) + xcodeproj (~> 0.17) + json (1.8.2) + minitest (5.5.1) + molinillo (0.1.2) + motion-cocoapods (1.7.0) + cocoapods (>= 0.34) + motion-require (0.2.0) + motion-sparkle (0.0.5) + nap (0.8.0) + netrc (0.7.8) + open4 (1.3.4) + rake (10.4.2) + sugarcube (3.1.1) + thor (0.15.4) + thread_safe (0.3.4) + tilt (1.4.1) + tzinfo (1.2.2) + thread_safe (~> 0.1) + xcodeproj (0.20.2) + activesupport (>= 3) colored (~> 1.2) - rake PLATFORMS ruby DEPENDENCIES - bubble-wrap (~> 1.4.0) - ib (~> 0.4.3) + afmotion + bubble-wrap + ib kyan_jukebox! - motion-cocoapods (~> 1.4.0) - motion-sparkle (~> 0.0.3)! + motion-cocoapods + motion-sparkle rake - sugarcube (~> 1.3.7) + sugarcube diff --git a/Rakefile b/Rakefile index 46d74df..aae995d 100644 --- a/Rakefile +++ b/Rakefile @@ -6,7 +6,6 @@ require 'bundler' Bundler.require require 'bubble-wrap/core' -require 'bubble-wrap/http' Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. @@ -14,6 +13,7 @@ Motion::Project::App.setup do |app| app.icon = "icon.icns" app.identifier = 'com.kyan.kyanbar' app.deployment_target = '10.8' + app.codesign_for_release = false app.info_plist['NSUIElement'] = 1 app.info_plist['NSHumanReadableCopyright'] = 'Copyright © 2013, Kyan Ltd' @@ -21,12 +21,13 @@ Motion::Project::App.setup do |app| app.pods do pod 'SocketRocket' pod 'MASShortcut' + pod "AFNetworking", "~> 2.0" end app.sparkle do release :base_url, 'https://raw.github.com/kyan/kyan_bar/master' - release :package_url, 'https://github.com/kyan/kyan_bar/releases/download' - release :version, '1.3.1' + release :package_base_url, 'https://github.com/kyan/kyan_bar/releases/download' + release :version, '1.3.3' # Optional settings release :feed_filename, 'releases.xml' diff --git a/app/_buttons/vote_button.rb b/app/_buttons/vote_button.rb index 6475c66..3625f8b 100644 --- a/app/_buttons/vote_button.rb +++ b/app/_buttons/vote_button.rb @@ -9,6 +9,7 @@ def initWithVote vote button.setBezelStyle(NSTexturedSquareBezelStyle) button.setButtonType(NSMomentaryPushButton) button.setAction "register_vote:" + button.setFocusRingType(NSFocusRingTypeNone) if vote button.cell.setImage(NSImage.imageNamed(NSImageNameAddTemplate)) diff --git a/app/_views/nowplaying_view.rb b/app/_views/nowplaying_view.rb index beff0a1..ee02b7f 100644 --- a/app/_views/nowplaying_view.rb +++ b/app/_views/nowplaying_view.rb @@ -22,6 +22,7 @@ def initWithFrame(frame) @metrics_dict = { "padding" => GLOBAL_H_PADDING, + "vpadding" => 5, "image_side" => 50, "h_spacing" => 5, "title_h" => 18, @@ -37,7 +38,7 @@ def initWithFrame(frame) constraints = [] constraints += NSLayoutConstraint.constraintsWithVisualFormat( - "V:|[image(==image_side)]|", + "V:|-vpadding-[image(==image_side)]|", options:NSLayoutFormatAlignAllLeft, metrics:metrics_dict, views:views_dict @@ -67,7 +68,7 @@ def initWithFrame(frame) views:views_dict ) constraints += NSLayoutConstraint.constraintsWithVisualFormat( - "V:|-(-2)-[title(title_h)]-(-2)-[artist(artist_h)]-(-3)-[album(album_h)]-(-3)-[addedby(addedby_h)]", + "V:|-vpadding-[title(title_h)]-(-2)-[artist(artist_h)]-(-3)-[album(album_h)]-(-3)-[addedby(addedby_h)]", options:0, metrics:metrics_dict, views:views_dict diff --git a/app/_windows/jukebox_control_window.rb b/app/_windows/jukebox_control_window.rb index 2361152..20ff3bd 100644 --- a/app/_windows/jukebox_control_window.rb +++ b/app/_windows/jukebox_control_window.rb @@ -39,13 +39,14 @@ def build_views } metrics_dict = { - "padding" => GLOBAL_H_PADDING, - "padding_t" => 9, - "padding_small" => 4, - "padding_vsmall" => 4, - "default_width" => 200, - "max_width" => 350, - "progress_h" => 1 + "padding" => GLOBAL_H_PADDING, + "padding_t" => 4, + "padding_t_vote_btn" => 10, + "padding_small" => 4, + "padding_vsmall" => 4, + "default_width" => 200, + "max_width" => 350, + "progress_h" => 1 } views_dictionary.each do |key, view| @@ -60,7 +61,7 @@ def build_views views:views_dictionary ) constraints += NSLayoutConstraint.constraintsWithVisualFormat( - "V:|-padding_t-[vote_buttons]-padding_small-[progress(progress_h)]-padding_vsmall-[vote_metrics]|", + "V:|-padding_t_vote_btn-[vote_buttons]-padding_small-[progress(progress_h)]-padding_vsmall-[vote_metrics]|", options:0, metrics:metrics_dict, views:views_dictionary diff --git a/app/app_delegate.rb b/app/app_delegate.rb index 3a2dedb..50c0bab 100644 --- a/app/app_delegate.rb +++ b/app/app_delegate.rb @@ -74,14 +74,14 @@ def register_defaults { SHOW_JB_DEFAULT => false } ) - MASShortcut.registerGlobalShortcutWithUserDefaultsKey( - U_VOTE_SHORTCUT_VAR, handler: lambda do + MASShortcutBinder.sharedBinder.bindShortcutWithDefaultsKey(U_VOTE_SHORTCUT_VAR, + toAction: lambda do VoteHandler.register(true) end ) - MASShortcut.registerGlobalShortcutWithUserDefaultsKey( - D_VOTE_SHORTCUT_VAR, handler: lambda do + MASShortcutBinder.sharedBinder.bindShortcutWithDefaultsKey(D_VOTE_SHORTCUT_VAR, + toAction: lambda do VoteHandler.register(false) end ) diff --git a/app/lib/vote_handler.rb b/app/lib/vote_handler.rb index 676d98c..e4c6a91 100644 --- a/app/lib/vote_handler.rb +++ b/app/lib/vote_handler.rb @@ -13,11 +13,11 @@ def self.register(vote) def register if valid? - BW::HTTP.get(vote_url) do |response| + AFMotion::HTTP.get(vote_url) do |response| if response.body.to_s.include?('login details incorrect') alert_creds_wrong else - response.ok? + response.success? end end else diff --git a/app/menu.rb b/app/menu.rb index e31e6f1..378329a 100644 --- a/app/menu.rb +++ b/app/menu.rb @@ -23,6 +23,11 @@ def build_menu(menu) menu.removeAllItems flags = (NSEvent.modifierFlags & NSDeviceIndependentModifierFlagsMask) + + # If you hold the ALT key and display the + # menu it will show an extra item that lets + # you refersh your connection to the jukebox + # if flags == NSAlternateKeyMask menu.addItem(build_secret_refresh) add_seperator_for(menu) diff --git a/ib.xcodeproj/Stubs.h b/ib.xcodeproj/Stubs.h index 7b57a15..2dc62d6 100644 --- a/ib.xcodeproj/Stubs.h +++ b/ib.xcodeproj/Stubs.h @@ -1,13 +1,13 @@ -// Generated by IB v0.4.3 gem. Do not edit it manually +// Generated by IB v0.7.2 gem. Do not edit it manually // Run `rake ib:open` to refresh #import -#import -#import -#import #import +#import #import +#import #import +#import @interface VoteButton: NSButton -(IBAction) initWithVote:(id) vote; @@ -31,6 +31,7 @@ -(IBAction) refresh:(id) jukebox; -(IBAction) track; -(IBAction) rating; +-(IBAction) time; -(IBAction) draw_title_box; -(IBAction) draw_artist_box; -(IBAction) draw_album_box; @@ -43,6 +44,18 @@ -(IBAction) update_image; -(IBAction) update_votes; -(IBAction) update_vote_txt; +-(IBAction) update_progress; + +@end + +@interface ProgressView: NSView +-(IBAction) init; +-(IBAction) tag; +-(IBAction) drawRect:(id) dirtyRect; +-(IBAction) increment_timer; +-(IBAction) progress_percent; +-(IBAction) progress; +-(IBAction) duration_to_seconds:(id) str; @end @@ -80,19 +93,22 @@ @end -@interface AppDelegate: UIResponder +@interface AppDelegate: NSObject -(IBAction) applicationDidFinishLaunching:(id) notification; -(IBAction) build_status; -(IBAction) build_preferences:(id) sender; -(IBAction) update_status_bar_icon:(id) active; -(IBAction) build_jukebox_controls; +-(IBAction) remove_jukebox_controls; -(IBAction) hide_jukebox_controls; +-(IBAction) show_jukebox_controls; -(IBAction) force_reconnect_to_websocket_server; -(IBAction) register_defaults; -(IBAction) build_jukebox; -(IBAction) jukebox; -(IBAction) connect_to_websocket_server; -(IBAction) update_jukebox_controls_button_state:(id) state; +-(IBAction) handle_websocket_connection:(id) n; @end diff --git a/ib.xcodeproj/Stubs.m b/ib.xcodeproj/Stubs.m index bd5b498..1bd0ce0 100644 --- a/ib.xcodeproj/Stubs.m +++ b/ib.xcodeproj/Stubs.m @@ -1,4 +1,4 @@ -// Generated by IB v0.4.3 gem. Do not edit it manually +// Generated by IB v0.7.2 gem. Do not edit it manually // Run `rake ib:open` to refresh #import "Stubs.h" @@ -12,6 +12,9 @@ @implementation AlbumArtView @implementation NowplayingView @end +@implementation ProgressView +@end + @implementation VoteButtonsView @end diff --git a/ib.xcodeproj/project.pbxproj b/ib.xcodeproj/project.pbxproj index 6a58608..99aca09 100644 --- a/ib.xcodeproj/project.pbxproj +++ b/ib.xcodeproj/project.pbxproj @@ -10,123 +10,80 @@ 46 objects - 0A45373855C641598E589B22 + 01C91A841A7ADE0879D896F3 includeInIndex 1 isa PBXFileReference lastKnownFileType - file.xib + sourcecode.c.h + name + MASShortcutView+Bindings.h path - Preferences.xib + Public/MASShortcut/MASShortcutView+Bindings.h sourceTree <group> - 0A89E5E6043F4468AFACF22C + 01E37F56D39606B632832E7A includeInIndex 1 isa PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFSecurityPolicy.h path - pivotal.png + Build/AFNetworking/AFSecurityPolicy.h sourceTree <group> - 0AD30B98AF4044E58820EF60 + 08B7A8E1ABEDBBA30603DCBE - buildSettings - - ALWAYS_SEARCH_USER_PATHS - NO - CLANG_CXX_LANGUAGE_STANDARD - gnu++0x - CLANG_CXX_LIBRARY - libc++ - CLANG_ENABLE_MODULES - YES - CLANG_ENABLE_OBJC_ARC - YES - CLANG_WARN_BOOL_CONVERSION - YES - CLANG_WARN_CONSTANT_CONVERSION - YES - CLANG_WARN_DIRECT_OBJC_ISA_USAGE - YES_ERROR - CLANG_WARN_EMPTY_BODY - YES - CLANG_WARN_ENUM_CONVERSION - YES - CLANG_WARN_INT_CONVERSION - YES - CLANG_WARN_OBJC_ROOT_CLASS - YES_ERROR - COPY_PHASE_STRIP - YES - GCC_C_LANGUAGE_STANDARD - gnu99 - GCC_DYNAMIC_NO_PIC - NO - GCC_OPTIMIZATION_LEVEL - 0 - GCC_PREPROCESSOR_DEFINITIONS - - DEBUG=1 - $(inherited) - - GCC_SYMBOLS_PRIVATE_EXTERN - NO - GCC_WARN_64_TO_32_BIT_CONVERSION - YES - GCC_WARN_ABOUT_RETURN_TYPE - YES_ERROR - GCC_WARN_UNDECLARED_SELECTOR - YES - GCC_WARN_UNINITIALIZED_AUTOS - YES - GCC_WARN_UNUSED_FUNCTION - YES - GCC_WARN_UNUSED_VARIABLE - YES - ONLY_ACTIVE_ARCH - YES - + children + isa - XCBuildConfiguration + PBXGroup name - Debug + Resources + path + vendor/Pods/Resources + sourceTree + <group> - 0E8F1BE485124AC68682ECD4 + 08DCE2A6A8EE5D927ACBBE11 - buildConfigurations - - 6773463F927745D492858F4A - 33C57BC1094E4E67A496FBC8 - - defaultConfigurationIsVisible - 0 - defaultConfigurationName - Release + includeInIndex + 1 isa - XCConfigurationList + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLSessionManager.h + path + Public/AFNetworking/AFURLSessionManager.h + sourceTree + <group> - 110C8C120B224E978D7B8C86 + 0C772996E3049841FDE68BC5 - children - - B9F523A3FF5E482D8804A7BC - 96914C421EBC4D8DA01A2CDA - D74FAED94B7A43A6BBF2A824 - 65FB64FD305349EE9A5E87A0 - E62B81D3ADA343A58C19C42C - + includeInIndex + 1 isa - PBXGroup + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLRequestSerialization.h + path + Public/AFNetworking/AFURLRequestSerialization.h sourceTree <group> - 187EB62E17794ED0BCD51B06 + 0D6353DAB3D62A01445DFECF includeInIndex 1 @@ -135,96 +92,67 @@ lastKnownFileType sourcecode.c.h name - base64.h + MASShortcutValidator.h path - SocketRocket/base64.h + Build/MASShortcut/MASShortcutValidator.h sourceTree <group> - 210B961C6E0144CEA6D5E7FE + 0F0CA3A60D7D9D4126A69ABD isa PBXFileReference lastKnownFileType wrapper.framework name - Cocoa.framework + QuartzCore.framework path - Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Cocoa.framework + Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/QuartzCore.framework sourceTree DEVELOPER_DIR - 231C7BB27C0041BE815D3351 + 111C44D1DE27620DF38EE734 - fileRef - F040F8C0884A45E89991D8EE + includeInIndex + 1 isa - PBXBuildFile + PBXFileReference + path + k_logo_bw_18x18.png + sourceTree + <group> - 257CC000A97A4414B2DB2E13 + 178F03A699AF1468D5CA0879 includeInIndex 1 isa PBXFileReference lastKnownFileType - sourcecode.c.objc + sourcecode.c.h + name + MASShortcutBinder.h path - Stubs.m + Build/MASShortcut/MASShortcutBinder.h sourceTree <group> - 2A228F41C5B24E988D095583 - - attributes - - LastUpgradeCheck - 0500 - - buildConfigurationList - 2ACAD499A39741D6BD255955 - compatibilityVersion - Xcode 3.2 - developmentRegion - English - hasScannedForEncodings - 0 - isa - PBXProject - knownRegions - - en - - mainGroup - 110C8C120B224E978D7B8C86 - productRefGroup - B9F523A3FF5E482D8804A7BC - projectDirPath - - projectReferences - - projectRoot - - targets - - F9725BFB76CC45D6BE7CD255 - - - 2ACAD499A39741D6BD255955 + 1A15A1DEC7096DE532A4AC9B - buildConfigurations - - 0AD30B98AF4044E58820EF60 - 7AEBAB2F2F40423886F2D17A - - defaultConfigurationIsVisible - 0 - defaultConfigurationName - Release + includeInIndex + 1 isa - XCConfigurationList + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcut.h + path + Public/MASShortcut/MASShortcut.h + sourceTree + <group> - 2F0F4CC472F34174BEE29A14 + 1AE01EB7097C6F62A854E476 includeInIndex 1 @@ -233,62 +161,28 @@ lastKnownFileType sourcecode.c.h name - MASShortcut+Monitoring.h + SRWebSocket.h path - MASShortcut/MASShortcut+Monitoring.h + Public/SocketRocket/SRWebSocket.h sourceTree <group> - 33C57BC1094E4E67A496FBC8 + 1E37CDFBCE1CF2C225B60E22 - buildSettings - - ALWAYS_SEARCH_USER_PATHS - NO - COMBINE_HIDPI_IMAGES - YES - COPY_PHASE_STRIP - NO - DSTROOT - /tmp/xcodeproj.dst - GCC_C_LANGUAGE_STANDARD - gnu99 - GCC_DYNAMIC_NO_PIC - NO - GCC_ENABLE_OBJC_EXCEPTIONS - YES - GCC_OPTIMIZATION_LEVEL - 0 - GCC_PRECOMPILE_PREFIX_HEADER - YES - GCC_PREPROCESSOR_DEFINITIONS - - DEBUG=1 - $(inherited) - - GCC_SYMBOLS_PRIVATE_EXTERN - NO - GCC_VERSION - com.apple.compilers.llvm.clang.1_0 - INSTALL_PATH - $(BUILT_PRODUCTS_DIR) - MACOSX_DEPLOYMENT_TARGET - 10.7 - OTHER_LDFLAGS - - PRODUCT_NAME - $(TARGET_NAME) - SDKROOT - macosx - SKIP_INSTALL - YES - + includeInIndex + 1 isa - XCBuildConfiguration + PBXFileReference + lastKnownFileType + sourcecode.c.h name - Debug + AFURLRequestSerialization.h + path + Build/AFNetworking/AFURLRequestSerialization.h + sourceTree + <group> - 38B3D272D4F44CA7959B0738 + 1F7F503BEF7367A50CD948E0 includeInIndex 1 @@ -296,12 +190,14 @@ PBXFileReference lastKnownFileType sourcecode.c.h + name + AFURLSessionManager.h path - ____Pods-MASShortcut-prefix.h + Build/AFNetworking/AFURLSessionManager.h sourceTree <group> - 3AE7049757714EC182F95BEB + 2493CFCC1AE81EAF127BF97E includeInIndex 1 @@ -310,46 +206,56 @@ lastKnownFileType sourcecode.c.h name - MASShortcut+UserDefaults.h + AFURLResponseSerialization.h path - MASShortcut/MASShortcut+UserDefaults.h + Public/AFNetworking/AFURLResponseSerialization.h sourceTree <group> - 3F6B638420DC4F349C43D7D4 + 25F7EDFEE11032FDA7D7DA04 - fileRef - F8604878C8C6485E996DA0F7 + includeInIndex + 1 isa - PBXBuildFile + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLResponseSerialization.h + path + Build/AFNetworking/AFURLResponseSerialization.h + sourceTree + <group> - 4676A3FDEFE84A5A9209CA4B + 27E66F04FBE9E4BAE98DA0DF buildActionMask 2147483647 files - C29C6EA30BF94491BA193C99 + 2DEA2623B392C1294A7C9748 isa PBXSourcesBuildPhase runOnlyForDeploymentPostprocessing 0 - 4BB6F2315F9A4B3CBF5A231E + 2C14B4B107DFB66CCCC1969E + includeInIndex + 1 isa PBXFileReference lastKnownFileType - wrapper.framework + sourcecode.c.h name - CoreData.framework + Shortcut.h path - Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreData.framework + Build/MASShortcut/Shortcut.h sourceTree - DEVELOPER_DIR + <group> - 54E8391ACD334AF492D9874D + 2DD499BDF58C6F3A039F305A includeInIndex 1 @@ -358,215 +264,164 @@ lastKnownFileType sourcecode.c.h name - NSData+SRB64Additions.h + MASKeyCodes.h path - SocketRocket/NSData+SRB64Additions.h + Build/MASShortcut/MASKeyCodes.h sourceTree <group> - 62F192D455F34C8AA072F3AC + 2DEA2623B392C1294A7C9748 + + fileRef + 8A0B7A01467F8BD12D71FC98 + isa + PBXBuildFile + + 2EA116E6C13D911BD16D76C3 includeInIndex 1 isa PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFHTTPRequestOperationManager.h path - k_logo_bw_18x18.png + Public/AFNetworking/AFHTTPRequestOperationManager.h sourceTree <group> - 65FB64FD305349EE9A5E87A0 + 324E7CE8DAB90E8B6D68C922 - children - - ABDACF36C38E4346A6BA5997 - 257CC000A97A4414B2DB2E13 - + includeInIndex + 1 isa - PBXGroup + PBXFileReference + lastKnownFileType + sourcecode.c.h name - Supporting Files + AFNetworkReachabilityManager.h path - ib.xcodeproj + Build/AFNetworking/AFNetworkReachabilityManager.h sourceTree <group> - 6773463F927745D492858F4A - - buildSettings - - ALWAYS_SEARCH_USER_PATHS - NO - COMBINE_HIDPI_IMAGES - YES - COPY_PHASE_STRIP - YES - DEBUG_INFORMATION_FORMAT - dwarf-with-dsym - DSTROOT - /tmp/xcodeproj.dst - GCC_C_LANGUAGE_STANDARD - gnu99 - GCC_ENABLE_OBJC_EXCEPTIONS - YES - GCC_PRECOMPILE_PREFIX_HEADER - YES - GCC_VERSION - com.apple.compilers.llvm.clang.1_0 - INSTALL_PATH - $(BUILT_PRODUCTS_DIR) - MACOSX_DEPLOYMENT_TARGET - 10.7 - OTHER_CFLAGS - - -DNS_BLOCK_ASSERTIONS=1 - $(inherited) - - OTHER_CPLUSPLUSFLAGS - - -DNS_BLOCK_ASSERTIONS=1 - $(inherited) - - OTHER_LDFLAGS - - PRODUCT_NAME - $(TARGET_NAME) - SDKROOT - macosx - SKIP_INSTALL - YES - - isa - XCBuildConfiguration - name - Release - - 696DAF15C47E4AAE8FE1BCCB + 32F4C41D692F73E5A04D3416 includeInIndex 1 isa PBXFileReference - lastKnownFileType - sourcecode.c.h - name - MASShortcut.h path - MASShortcut/MASShortcut.h + k_logo_col_18x18.png sourceTree <group> - 7649E986F3404B1D8D93D6CC + 3535DF77E7D671EC94B9BA57 includeInIndex 1 isa PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFSecurityPolicy.h path - jukebox.png + Public/AFNetworking/AFSecurityPolicy.h sourceTree <group> - 7811228F6DB84DB2B4406643 + 357543D5013BABFAD2135E11 includeInIndex 1 isa PBXFileReference + lastKnownFileType + file.xib path - support.png + Preferences.xib sourceTree <group> - 7AEBAB2F2F40423886F2D17A + 36E1AA3BEF6EB3194421B204 - buildSettings - - ALWAYS_SEARCH_USER_PATHS - NO - CLANG_CXX_LANGUAGE_STANDARD - gnu++0x - CLANG_CXX_LIBRARY - libc++ - CLANG_ENABLE_MODULES - YES - CLANG_ENABLE_OBJC_ARC - YES - CLANG_WARN_BOOL_CONVERSION - YES - CLANG_WARN_CONSTANT_CONVERSION - YES - CLANG_WARN_DIRECT_OBJC_ISA_USAGE - YES_ERROR - CLANG_WARN_EMPTY_BODY - YES - CLANG_WARN_ENUM_CONVERSION - YES - CLANG_WARN_INT_CONVERSION - YES - CLANG_WARN_OBJC_ROOT_CLASS - YES_ERROR - COPY_PHASE_STRIP - NO - ENABLE_NS_ASSERTIONS - NO - GCC_C_LANGUAGE_STANDARD - gnu99 - GCC_WARN_64_TO_32_BIT_CONVERSION - YES - GCC_WARN_ABOUT_RETURN_TYPE - YES_ERROR - GCC_WARN_UNDECLARED_SELECTOR - YES - GCC_WARN_UNINITIALIZED_AUTOS - YES - GCC_WARN_UNUSED_FUNCTION - YES - GCC_WARN_UNUSED_VARIABLE - YES - VALIDATE_PRODUCT - YES - isa - XCBuildConfiguration + PBXFileReference + lastKnownFileType + wrapper.framework name - Release + CoreGraphics.framework + path + Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreGraphics.framework + sourceTree + DEVELOPER_DIR - 8B4097954A8840C09E9D29CC + 3BA87ABD2C618CF917389A2A includeInIndex 1 isa PBXFileReference path - holiday.png + turd.png sourceTree <group> - 8C9F39B240F047AB98DCB446 + 3BF71BCA1BEF7FA4E79C49C8 - fileRef - 210B961C6E0144CEA6D5E7FE + includeInIndex + 1 isa - PBXBuildFile + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLConnectionOperation.h + path + Public/AFNetworking/AFURLConnectionOperation.h + sourceTree + <group> - 8CD195D83E1B47BB94C3795C + 3D18992869BCD98A402CF2C4 - children + attributes + + LastUpgradeCheck + 0510 + + buildConfigurationList + 8D9E59EB3389EDBEEDF397CB + compatibilityVersion + Xcode 3.2 + developmentRegion + English + hasScannedForEncodings + 0 + isa + PBXProject + knownRegions - 210B961C6E0144CEA6D5E7FE - F8604878C8C6485E996DA0F7 - F040F8C0884A45E89991D8EE - 4BB6F2315F9A4B3CBF5A231E + en + + mainGroup + 798DC8AC153027B218FA163F + productRefGroup + 853FBD7C7B3A6709251670C3 + projectDirPath + + projectReferences + + projectRoot + + targets + + E0AAD6C245861FCC922D98B4 - isa - PBXGroup - name - OS X - sourceTree - <group> - 8D2C94853CE24168871D16B0 + 3EC51CD0F7462D2587291CA2 includeInIndex 1 @@ -575,46 +430,35 @@ lastKnownFileType sourcecode.c.h name - SRWebSocket.h + base64.h path - SocketRocket/SRWebSocket.h + Public/SocketRocket/base64.h sourceTree <group> - 8E2470ABD50649E990312B73 + 42A48F71CE238AC8BEAA976F includeInIndex 1 isa PBXFileReference - lastKnownFileType - sourcecode.c.h path - ____Pods-SocketRocket-prefix.h + holiday.png sourceTree <group> - 918CA42C0DD548608F006411 - - fileRef - 4BB6F2315F9A4B3CBF5A231E - isa - PBXBuildFile - - 96914C421EBC4D8DA01A2CDA + 451EE5FE1CC47EA72CD6D23D - children - - 8CD195D83E1B47BB94C3795C - + includeInIndex + 1 isa - PBXGroup - name - Frameworks + PBXFileReference + path + timesheet.png sourceTree <group> - ABDACF36C38E4346A6BA5997 + 46AAE60AD9D47B843F0F8E33 includeInIndex 1 @@ -622,12 +466,14 @@ PBXFileReference lastKnownFileType sourcecode.c.h + name + base64.h path - Stubs.h + Build/SocketRocket/base64.h sourceTree <group> - B7AD66F5E5804D9F9052851D + 46F9EB166D59735AD7ABED6B includeInIndex 1 @@ -636,171 +482,787 @@ lastKnownFileType sourcecode.c.h name - MASShortcutView.h + MASHotKey.h path - MASShortcut/MASShortcutView.h + Build/MASShortcut/MASHotKey.h sourceTree <group> - B7E30F4F40344A56A028113F - - buildActionMask - 2147483647 - files - - 8C9F39B240F047AB98DCB446 - 3F6B638420DC4F349C43D7D4 - 231C7BB27C0041BE815D3351 - 918CA42C0DD548608F006411 - - isa - PBXFrameworksBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - B9F523A3FF5E482D8804A7BC + 472654D0B1508D80C389D301 - children - - BBD82AFC633E4AB38FA50CA3 - + includeInIndex + 1 isa - PBXGroup + PBXFileReference + lastKnownFileType + sourcecode.c.h name - Products + AFNetworking.h + path + Public/AFNetworking/AFNetworking.h sourceTree <group> - BBD82AFC633E4AB38FA50CA3 + 4CF3CD357C9F9BF3598F9160 - explicitFileType - archive.ar includeInIndex - 0 + 1 isa PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASKeyCodes.h path - libib.a + Public/MASShortcut/MASKeyCodes.h sourceTree - BUILT_PRODUCTS_DIR + <group> - BD568056560D4849BF72D8D0 + 50FA3E5C4EBA78AC59B18036 includeInIndex 1 isa PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcut.h path - turd.png + Build/MASShortcut/MASShortcut.h sourceTree <group> - C29C6EA30BF94491BA193C99 - - fileRef - 257CC000A97A4414B2DB2E13 - isa - PBXBuildFile - - D74FAED94B7A43A6BBF2A824 + 52F111624E3693D427EEB201 children - EB8CA9FB546A45508C36D75A - 8B4097954A8840C09E9D29CC - 7649E986F3404B1D8D93D6CC - 62F192D455F34C8AA072F3AC - F57C8FC77F05498BAE9523F2 - F182B4F9F1E24EC08B36A394 - 0A89E5E6043F4468AFACF22C - 7811228F6DB84DB2B4406643 - E515E622A4EB435595805321 - BD568056560D4849BF72D8D0 - 0A45373855C641598E589B22 + 77DB37D5BEB309F9BE8E3E74 isa PBXGroup name - Resources - path - resources + Frameworks sourceTree <group> - E2B19DA176EC4A98BF94DEDB + 5783DB8CFEF486779D11F0D7 - includeInIndex - 1 isa PBXFileReference lastKnownFileType - sourcecode.c.h + wrapper.framework + name + Cocoa.framework path - ____Pods-environment.h + Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Cocoa.framework sourceTree - <group> + DEVELOPER_DIR - E515E622A4EB435595805321 + 5E1E884A2561365C33F123DB includeInIndex 1 isa PBXFileReference path - timesheet.png + support.png sourceTree <group> - E62B81D3ADA343A58C19C42C + 6270C067DF56524C4DA0EB62 - children - - E2B19DA176EC4A98BF94DEDB - 38B3D272D4F44CA7959B0738 - 8E2470ABD50649E990312B73 - 2F0F4CC472F34174BEE29A14 - 3AE7049757714EC182F95BEB - 696DAF15C47E4AAE8FE1BCCB - FB080052DBC348FAAE78A9F2 - B7AD66F5E5804D9F9052851D - 187EB62E17794ED0BCD51B06 - 54E8391ACD334AF492D9874D - 8D2C94853CE24168871D16B0 - + includeInIndex + 1 isa - PBXGroup + PBXFileReference + lastKnownFileType + sourcecode.c.h name - Pods + MASDictionaryTransformer.h path - vendor/Pods/Headers + Build/MASShortcut/MASDictionaryTransformer.h sourceTree <group> - EB8CA9FB546A45508C36D75A + 651845FBBE3CCAC78DF3AA67 - includeInIndex - 1 + fileRef + DB69E05F8E0496B5967E669D + isa + PBXBuildFile + + 66EF6A475772899DC1059E27 + + fileRef + 0F0CA3A60D7D9D4126A69ABD + isa + PBXBuildFile + + 6A1814AAFDECA0CD6371E990 + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + COMBINE_HIDPI_IMAGES + YES + COPY_PHASE_STRIP + NO + DSTROOT + /tmp/xcodeproj.dst + GCC_DYNAMIC_NO_PIC + NO + GCC_ENABLE_OBJC_EXCEPTIONS + YES + GCC_OPTIMIZATION_LEVEL + 0 + GCC_PRECOMPILE_PREFIX_HEADER + YES + GCC_PREPROCESSOR_DEFINITIONS + + DEBUG=1 + $(inherited) + + GCC_SYMBOLS_PRIVATE_EXTERN + NO + GCC_VERSION + com.apple.compilers.llvm.clang.1_0 + INSTALL_PATH + $(BUILT_PRODUCTS_DIR) + MACOSX_DEPLOYMENT_TARGET + 10.7 + OTHER_LDFLAGS + + PRODUCT_NAME + $(TARGET_NAME) + SDKROOT + macosx + SKIP_INSTALL + YES + + isa + XCBuildConfiguration + name + Debug + + 6E33F09444289C9C9718E2B7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFHTTPSessionManager.h + path + Build/AFNetworking/AFHTTPSessionManager.h + sourceTree + <group> + + 735445D7783D3CFC817EA794 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + NSData+SRB64Additions.h + path + Public/SocketRocket/NSData+SRB64Additions.h + sourceTree + <group> + + 73F1951F19BF3E2AB7787EB3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcutView.h + path + Public/MASShortcut/MASShortcutView.h + sourceTree + <group> + + 77DB37D5BEB309F9BE8E3E74 + + children + + 5783DB8CFEF486779D11F0D7 + 0F0CA3A60D7D9D4126A69ABD + 36E1AA3BEF6EB3194421B204 + DB69E05F8E0496B5967E669D + + isa + PBXGroup + name + OS X + sourceTree + <group> + + 798DC8AC153027B218FA163F + + children + + 853FBD7C7B3A6709251670C3 + 52F111624E3693D427EEB201 + EE05F2ED85A5C738D1A555E0 + 79AFC4BDC17B8A450DAF7BCF + 8B6DFA62CAD4869B3F29C8F7 + + isa + PBXGroup + sourceTree + <group> + + 79AFC4BDC17B8A450DAF7BCF + + children + + A3BE4E151EC24ABC7E8BA88C + B8D2D9062234FCA9EB9DA2F1 + 6E33F09444289C9C9718E2B7 + E6A607A03260166E5BE389D9 + 324E7CE8DAB90E8B6D68C922 + 01E37F56D39606B632832E7A + 9EB623F2ADCECFB42CB3B4C6 + 1E37CDFBCE1CF2C225B60E22 + 25F7EDFEE11032FDA7D7DA04 + 1F7F503BEF7367A50CD948E0 + 6270C067DF56524C4DA0EB62 + 46F9EB166D59735AD7ABED6B + 2DD499BDF58C6F3A039F305A + 50FA3E5C4EBA78AC59B18036 + 178F03A699AF1468D5CA0879 + C16717F84848360742F59B88 + 0D6353DAB3D62A01445DFECF + 9215B3E5872B942A995B5386 + AD530E46017E9F6612E4A6F7 + 2C14B4B107DFB66CCCC1969E + 46AAE60AD9D47B843F0F8E33 + E1A7D90B58AA54B59FFC8CD1 + 9D53E2A88E2683ECD974CA10 + E6862E98939A4419F4D4CB20 + DA04E0491A49EBAC65574D87 + FA56790F18BC2339162A43F4 + E3C44A98B2026D76A0CD9FBE + E446704F0BFD97B4750858C7 + 2EA116E6C13D911BD16D76C3 + 940BBEAC363B76FA8BA24A18 + 472654D0B1508D80C389D301 + A5969CC12D85485F0FC75DC5 + 3535DF77E7D671EC94B9BA57 + 3BF71BCA1BEF7FA4E79C49C8 + 0C772996E3049841FDE68BC5 + 2493CFCC1AE81EAF127BF97E + 08DCE2A6A8EE5D927ACBBE11 + DFA7C1DA1352315CA336DDF4 + 7B6B631F27A9C47601807DFC + 4CF3CD357C9F9BF3598F9160 + 1A15A1DEC7096DE532A4AC9B + 86CA9B2DDDF639CD4217FC00 + C0B7A00E43398A730AD76473 + C36E481BA1F98767CF8A1FFE + 01C91A841A7ADE0879D896F3 + 73F1951F19BF3E2AB7787EB3 + EBD467A66C49DFB666D9BEA6 + 3EC51CD0F7462D2587291CA2 + 735445D7783D3CFC817EA794 + 1AE01EB7097C6F62A854E476 + + isa + PBXGroup + name + Pods + path + /Users/duncan/_dev/osx/KyanBar/vendor/Pods/Headers + sourceTree + <group> + + 7B6B631F27A9C47601807DFC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASHotKey.h + path + Public/MASShortcut/MASHotKey.h + sourceTree + <group> + + 853FBD7C7B3A6709251670C3 + + children + + B0C06F28349FF114F601F552 + + isa + PBXGroup + name + Products + sourceTree + <group> + + 86C0047D84113081D9FE144B + + fileRef + 5783DB8CFEF486779D11F0D7 + isa + PBXBuildFile + + 86CA9B2DDDF639CD4217FC00 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcutBinder.h + path + Public/MASShortcut/MASShortcutBinder.h + sourceTree + <group> + + 8A0B7A01467F8BD12D71FC98 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + Stubs.m + sourceTree + <group> + + 8B17AE22B1C042DF23C0B94B + + buildActionMask + 2147483647 + files + + 86C0047D84113081D9FE144B + 66EF6A475772899DC1059E27 + 9352A4D4380B4810E92DD486 + 651845FBBE3CCAC78DF3AA67 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 8B6DFA62CAD4869B3F29C8F7 + + children + + F41723297D115D530E051B5C + 08B7A8E1ABEDBBA30603DCBE + + isa + PBXGroup + name + Resources + sourceTree + <group> + + 8D9E59EB3389EDBEEDF397CB + + buildConfigurations + + FD78BEE0163A5234C99EC86F + E9B9DFDE37E68F07A0266E7C + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 9215B3E5872B942A995B5386 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcutView+Bindings.h + path + Build/MASShortcut/MASShortcutView+Bindings.h + sourceTree + <group> + + 9352A4D4380B4810E92DD486 + + fileRef + 36E1AA3BEF6EB3194421B204 + isa + PBXBuildFile + + 940BBEAC363B76FA8BA24A18 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFHTTPSessionManager.h + path + Public/AFNetworking/AFHTTPSessionManager.h + sourceTree + <group> + + 9D53E2A88E2683ECD974CA10 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + SRWebSocket.h + path + Build/SocketRocket/SRWebSocket.h + sourceTree + <group> + + 9EB623F2ADCECFB42CB3B4C6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLConnectionOperation.h + path + Build/AFNetworking/AFURLConnectionOperation.h + sourceTree + <group> + + A00B81197169D26476B74181 + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + COMBINE_HIDPI_IMAGES + YES + COPY_PHASE_STRIP + YES + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DSTROOT + /tmp/xcodeproj.dst + GCC_ENABLE_OBJC_EXCEPTIONS + YES + GCC_PRECOMPILE_PREFIX_HEADER + YES + GCC_VERSION + com.apple.compilers.llvm.clang.1_0 + INSTALL_PATH + $(BUILT_PRODUCTS_DIR) + MACOSX_DEPLOYMENT_TARGET + 10.7 + OTHER_CFLAGS + + -DNS_BLOCK_ASSERTIONS=1 + $(inherited) + + OTHER_CPLUSPLUSFLAGS + + -DNS_BLOCK_ASSERTIONS=1 + $(inherited) + + OTHER_LDFLAGS + + PRODUCT_NAME + $(TARGET_NAME) + SDKROOT + macosx + SKIP_INSTALL + YES + + isa + XCBuildConfiguration + name + Release + + A3BE4E151EC24ABC7E8BA88C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFHTTPRequestOperation.h + path + Build/AFNetworking/AFHTTPRequestOperation.h + sourceTree + <group> + + A5969CC12D85485F0FC75DC5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFNetworkReachabilityManager.h + path + Public/AFNetworking/AFNetworkReachabilityManager.h + sourceTree + <group> + + AD530E46017E9F6612E4A6F7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcutView.h + path + Build/MASShortcut/MASShortcutView.h + sourceTree + <group> + + B0C06F28349FF114F601F552 + + explicitFileType + archive.ar + includeInIndex + 0 + isa + PBXFileReference + path + libib.a + sourceTree + BUILT_PRODUCTS_DIR + + B8D2D9062234FCA9EB9DA2F1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFHTTPRequestOperationManager.h + path + Build/AFNetworking/AFHTTPRequestOperationManager.h + sourceTree + <group> + + B8D8AA5AFFD369563A29127B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + Stubs.h + sourceTree + <group> + + C0B7A00E43398A730AD76473 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcutMonitor.h + path + Public/MASShortcut/MASShortcutMonitor.h + sourceTree + <group> + + C16717F84848360742F59B88 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcutMonitor.h + path + Build/MASShortcut/MASShortcutMonitor.h + sourceTree + <group> + + C308C106F51702CC5B60CB54 + + includeInIndex + 1 + isa + PBXFileReference + path + pivotal.png + sourceTree + <group> + + C36E481BA1F98767CF8A1FFE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcutValidator.h + path + Public/MASShortcut/MASShortcutValidator.h + sourceTree + <group> + + DA04E0491A49EBAC65574D87 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + ____Pods-environment.h + path + Public/____Pods-environment.h + sourceTree + <group> + + DB69E05F8E0496B5967E669D + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + CoreData.framework + path + Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreData.framework + sourceTree + DEVELOPER_DIR + + DFA7C1DA1352315CA336DDF4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASDictionaryTransformer.h + path + Public/MASShortcut/MASDictionaryTransformer.h + sourceTree + <group> + + E0AAD6C245861FCC922D98B4 + + buildConfigurationList + F0E18AC1E34A2C90B4B4CE42 + buildPhases + + 27E66F04FBE9E4BAE98DA0DF + 8B17AE22B1C042DF23C0B94B + + buildRules + + dependencies + + isa + PBXNativeTarget + name + ib + productName + ib + productReference + B0C06F28349FF114F601F552 + productType + com.apple.product-type.library.static + + E1A7D90B58AA54B59FFC8CD1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + NSData+SRB64Additions.h + path + Build/SocketRocket/NSData+SRB64Additions.h + sourceTree + <group> + + E3C44A98B2026D76A0CD9FBE + + includeInIndex + 1 isa PBXFileReference + lastKnownFileType + sourcecode.c.h + name + ____Pods-SocketRocket-prefix.h path - campfire.png + Public/____Pods-SocketRocket-prefix.h sourceTree <group> - F040F8C0884A45E89991D8EE + E446704F0BFD97B4750858C7 + includeInIndex + 1 isa PBXFileReference lastKnownFileType - wrapper.framework + sourcecode.c.h name - CoreGraphics.framework + AFHTTPRequestOperation.h path - Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreGraphics.framework + Public/AFNetworking/AFHTTPRequestOperation.h sourceTree - DEVELOPER_DIR + <group> - F182B4F9F1E24EC08B36A394 + E485E6891AAFD58CC51DE1F5 includeInIndex 1 @@ -811,55 +1273,183 @@ sourceTree <group> - F57C8FC77F05498BAE9523F2 + E6862E98939A4419F4D4CB20 includeInIndex 1 isa PBXFileReference + lastKnownFileType + sourcecode.c.h + name + ____Pods-AFNetworking-prefix.h path - k_logo_col_18x18.png + Public/____Pods-AFNetworking-prefix.h sourceTree <group> - F8604878C8C6485E996DA0F7 + E6A607A03260166E5BE389D9 + includeInIndex + 1 isa PBXFileReference lastKnownFileType - wrapper.framework + sourcecode.c.h name - QuartzCore.framework + AFNetworking.h path - Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/QuartzCore.framework + Build/AFNetworking/AFNetworking.h sourceTree - DEVELOPER_DIR + <group> - F9725BFB76CC45D6BE7CD255 + E9B9DFDE37E68F07A0266E7C - buildConfigurationList - 0E8F1BE485124AC68682ECD4 - buildPhases + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + COPY_PHASE_STRIP + NO + ENABLE_NS_ASSERTIONS + NO + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + VALIDATE_PRODUCT + YES + + isa + XCBuildConfiguration + name + Release + + EBD467A66C49DFB666D9BEA6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + Shortcut.h + path + Public/MASShortcut/Shortcut.h + sourceTree + <group> + + EE05F2ED85A5C738D1A555E0 + + children - 4676A3FDEFE84A5A9209CA4B - B7E30F4F40344A56A028113F + B8D8AA5AFFD369563A29127B + 8A0B7A01467F8BD12D71FC98 - buildRules - - dependencies - isa - PBXNativeTarget + PBXGroup name - ib - productName - ib - productReference - BBD82AFC633E4AB38FA50CA3 - productType - com.apple.product-type.library.static + Supporting Files + path + /Users/duncan/_dev/osx/KyanBar/ib.xcodeproj + sourceTree + <group> + + F0E18AC1E34A2C90B4B4CE42 + + buildConfigurations + + A00B81197169D26476B74181 + 6A1814AAFDECA0CD6371E990 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + F3987DE68A4FEE2D769DA7EE + + includeInIndex + 1 + isa + PBXFileReference + path + campfire.png + sourceTree + <group> + + F41723297D115D530E051B5C + + children + + F3987DE68A4FEE2D769DA7EE + 42A48F71CE238AC8BEAA976F + F6DDE76AC6B328D6CA27C564 + 111C44D1DE27620DF38EE734 + 32F4C41D692F73E5A04D3416 + E485E6891AAFD58CC51DE1F5 + C308C106F51702CC5B60CB54 + 5E1E884A2561365C33F123DB + 451EE5FE1CC47EA72CD6D23D + 3BA87ABD2C618CF917389A2A + 357543D5013BABFAD2135E11 + + isa + PBXGroup + name + resources + path + ./resources + sourceTree + <group> + + F6DDE76AC6B328D6CA27C564 + + includeInIndex + 1 + isa + PBXFileReference + path + jukebox.png + sourceTree + <group> - FB080052DBC348FAAE78A9F2 + FA56790F18BC2339162A43F4 includeInIndex 1 @@ -868,14 +1458,77 @@ lastKnownFileType sourcecode.c.h name - MASShortcutView+UserDefaults.h + ____Pods-MASShortcut-prefix.h path - MASShortcut/MASShortcutView+UserDefaults.h + Public/____Pods-MASShortcut-prefix.h sourceTree <group> + FD78BEE0163A5234C99EC86F + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + COPY_PHASE_STRIP + YES + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_DYNAMIC_NO_PIC + NO + GCC_OPTIMIZATION_LEVEL + 0 + GCC_PREPROCESSOR_DEFINITIONS + + DEBUG=1 + $(inherited) + + GCC_SYMBOLS_PRIVATE_EXTERN + NO + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + ONLY_ACTIVE_ARCH + YES + + isa + XCBuildConfiguration + name + Debug + rootObject - 2A228F41C5B24E988D095583 + 3D18992869BCD98A402CF2C4 diff --git a/ib.xcodeproj/project.xcworkspace/xcshareddata/ib.xccheckout b/ib.xcodeproj/project.xcworkspace/xcshareddata/ib.xccheckout index 539e59c..a05fde6 100644 --- a/ib.xcodeproj/project.xcworkspace/xcshareddata/ib.xccheckout +++ b/ib.xcodeproj/project.xcworkspace/xcshareddata/ib.xccheckout @@ -10,29 +10,29 @@ ib IDESourceControlProjectOriginsDictionary - 5B198CB3-9134-499D-AD5F-51A4CFA44971 - ssh://github.com/kyan/kyan_bar.git + 216C31E7C24BBD512146743D52E6A3E35A142F5D + github.com:kyan/kyan_bar.git IDESourceControlProjectPath - ib.xcodeproj/project.xcworkspace + ib.xcodeproj IDESourceControlProjectRelativeInstallPathDictionary - 5B198CB3-9134-499D-AD5F-51A4CFA44971 + 216C31E7C24BBD512146743D52E6A3E35A142F5D ../.. IDESourceControlProjectURL - ssh://github.com/kyan/kyan_bar.git + github.com:kyan/kyan_bar.git IDESourceControlProjectVersion - 110 + 111 IDESourceControlProjectWCCIdentifier - 5B198CB3-9134-499D-AD5F-51A4CFA44971 + 216C31E7C24BBD512146743D52E6A3E35A142F5D IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - 5B198CB3-9134-499D-AD5F-51A4CFA44971 + 216C31E7C24BBD512146743D52E6A3E35A142F5D IDESourceControlWCCName KyanBar diff --git a/ib.xcodeproj/project.xcworkspace/xcuserdata/duncan.xcuserdatad/UserInterfaceState.xcuserstate b/ib.xcodeproj/project.xcworkspace/xcuserdata/duncan.xcuserdatad/UserInterfaceState.xcuserstate index ca13797..7b9a53a 100644 Binary files a/ib.xcodeproj/project.xcworkspace/xcuserdata/duncan.xcuserdatad/UserInterfaceState.xcuserstate and b/ib.xcodeproj/project.xcworkspace/xcuserdata/duncan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ib.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/xcschememanagement.plist b/ib.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/xcschememanagement.plist index 6b60732..943627d 100644 --- a/ib.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/ib.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/xcschememanagement.plist @@ -52,6 +52,11 @@ primary + E0AAD6C245861FCC922D98B4 + + primary + + EA05158828C240349470CD36 primary diff --git a/vendor/Podfile.lock b/vendor/Podfile.lock index 4278b64..0d2e2bb 100644 --- a/vendor/Podfile.lock +++ b/vendor/Podfile.lock @@ -1,13 +1,33 @@ PODS: - - MASShortcut (1.2.3) - - SocketRocket (0.3.1-beta2) + - AFNetworking (2.5.0): + - AFNetworking/NSURLConnection (= 2.5.0) + - AFNetworking/NSURLSession (= 2.5.0) + - AFNetworking/Reachability (= 2.5.0) + - AFNetworking/Security (= 2.5.0) + - AFNetworking/Serialization (= 2.5.0) + - AFNetworking/UIKit (= 2.5.0) + - AFNetworking/NSURLConnection (2.5.0): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/NSURLSession (2.5.0): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (2.5.0) + - AFNetworking/Security (2.5.0) + - AFNetworking/Serialization (2.5.0) + - MASShortcut (2.1.1) + - SocketRocket (0.2.0) DEPENDENCIES: + - AFNetworking (~> 2.0) - MASShortcut - SocketRocket SPEC CHECKSUMS: - MASShortcut: 6abaedac53a0542f4856f35be4f1f970b652a51e - SocketRocket: 7ac946bcce46287a791dfff3c1f8daa692821dae + AFNetworking: 0f54cb5d16ce38c1b76948faffb8d5fb705021c7 + MASShortcut: eaf6fc60ae9742d21312b2463c4ac25bcdb27f24 + SocketRocket: 6c9cfd1592bea82262b4283dcda3a7de166af3b6 -COCOAPODS: 0.29.0 +COCOAPODS: 0.35.0 diff --git a/vendor/Pods/.build/libPods-AFNetworking.a b/vendor/Pods/.build/libPods-AFNetworking.a new file mode 100644 index 0000000..c92d889 Binary files /dev/null and b/vendor/Pods/.build/libPods-AFNetworking.a differ diff --git a/vendor/Pods/.build/libPods-MASShortcut.a b/vendor/Pods/.build/libPods-MASShortcut.a new file mode 100644 index 0000000..395ff1e Binary files /dev/null and b/vendor/Pods/.build/libPods-MASShortcut.a differ diff --git a/vendor/Pods/.build/libPods-SocketRocket.a b/vendor/Pods/.build/libPods-SocketRocket.a new file mode 100644 index 0000000..4724d6f Binary files /dev/null and b/vendor/Pods/.build/libPods-SocketRocket.a differ diff --git a/vendor/Pods/.build/libPods.a b/vendor/Pods/.build/libPods.a new file mode 100644 index 0000000..70798dd Binary files /dev/null and b/vendor/Pods/.build/libPods.a differ diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h new file mode 100644 index 0000000..dfa82f6 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h @@ -0,0 +1,67 @@ +// AFHTTPRequestOperation.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import "AFURLConnectionOperation.h" + +/** + `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. + */ +@interface AFHTTPRequestOperation : AFURLConnectionOperation + +///------------------------------------------------ +/// @name Getting HTTP URL Connection Information +///------------------------------------------------ + +/** + The last HTTP response received by the operation's connection. + */ +@property (readonly, nonatomic, strong) NSHTTPURLResponse *response; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an AFHTTPResponse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. + + @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +/** + An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error. + */ +@property (readonly, nonatomic, strong) id responseObject; + +///----------------------------------------------------------- +/// @name Setting Completion Block Success / Failure Callbacks +///----------------------------------------------------------- + +/** + Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. + + This method should be overridden in subclasses in order to specify the response object passed into the success block. + + @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. + @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. + */ +- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +@end diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m new file mode 100644 index 0000000..1de5812 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m @@ -0,0 +1,206 @@ +// AFHTTPRequestOperation.m +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFHTTPRequestOperation.h" + +static dispatch_queue_t http_request_operation_processing_queue() { + static dispatch_queue_t af_http_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_http_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.http-request.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_http_request_operation_processing_queue; +} + +static dispatch_group_t http_request_operation_completion_group() { + static dispatch_group_t af_http_request_operation_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_http_request_operation_completion_group = dispatch_group_create(); + }); + + return af_http_request_operation_completion_group; +} + +#pragma mark - + +@interface AFURLConnectionOperation () +@property (readwrite, nonatomic, strong) NSURLRequest *request; +@property (readwrite, nonatomic, strong) NSURLResponse *response; +@end + +@interface AFHTTPRequestOperation () +@property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; +@property (readwrite, nonatomic, strong) id responseObject; +@property (readwrite, nonatomic, strong) NSError *responseSerializationError; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; +@end + +@implementation AFHTTPRequestOperation +@dynamic lock; + +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { + self = [super initWithRequest:urlRequest]; + if (!self) { + return nil; + } + + self.responseSerializer = [AFHTTPResponseSerializer serializer]; + + return self; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [self.lock lock]; + _responseSerializer = responseSerializer; + self.responseObject = nil; + self.responseSerializationError = nil; + [self.lock unlock]; +} + +- (id)responseObject { + [self.lock lock]; + if (!_responseObject && [self isFinished] && !self.error) { + NSError *error = nil; + self.responseObject = [self.responseSerializer responseObjectForResponse:self.response data:self.responseData error:&error]; + if (error) { + self.responseSerializationError = error; + } + } + [self.lock unlock]; + + return _responseObject; +} + +- (NSError *)error { + if (_responseSerializationError) { + return _responseSerializationError; + } else { + return [super error]; + } +} + +#pragma mark - AFHTTPRequestOperation + +- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" + self.completionBlock = ^{ + if (self.completionGroup) { + dispatch_group_enter(self.completionGroup); + } + + dispatch_async(http_request_operation_processing_queue(), ^{ + if (self.error) { + if (failure) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + id responseObject = self.responseObject; + if (self.error) { + if (failure) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + if (success) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + success(self, responseObject); + }); + } + } + } + + if (self.completionGroup) { + dispatch_group_leave(self.completionGroup); + } + }); + }; +#pragma clang diagnostic pop +} + +#pragma mark - AFURLRequestOperation + +- (void)pause { + [super pause]; + + u_int64_t offset = 0; + if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { + offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue]; + } else { + offset = [(NSData *)[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length]; + } + + NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy]; + if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) { + [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"]; + } + [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"]; + self.request = mutableURLRequest; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestOperation *operation = [super copyWithZone:zone]; + + operation.responseSerializer = [self.responseSerializer copyWithZone:zone]; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +@end diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h new file mode 100644 index 0000000..9f39029 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h @@ -0,0 +1,308 @@ +// AFHTTPRequestOperationManager.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import +#import + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +#import "AFHTTPRequestOperation.h" +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#import "AFNetworkReachabilityManager.h" + +/** + `AFHTTPRequestOperationManager` encapsulates the common patterns of communicating with a web application over HTTP, including request creation, response serialization, network reachability monitoring, and security, as well as request operation management. + + ## Subclassing Notes + + Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. + + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. + + ## Methods to Override + + To change the behavior of all request operation construction for an `AFHTTPRequestOperationManager` subclass, override `HTTPRequestOperationWithRequest:success:failure`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. + + ## Network Reachability Monitoring + + Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. + + ## NSSecureCoding & NSCopying Caveats + + `AFHTTPRequestOperationManager` conforms to the `NSSecureCoding` 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. + - NSSecureCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set. + */ +@interface AFHTTPRequestOperationManager : NSObject + +/** + The URL used to monitor reachability, and construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong) NSURL *baseURL; + +/** + Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to a JSON serializer, which serializes data from responses with a `application/json` MIME type, and falls back to the raw data object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +/** + The operation queue on which request operations are scheduled and run. + */ +@property (nonatomic, strong) NSOperationQueue *operationQueue; + +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Whether request operations should consult the credential storage for authenticating the connection. `YES` by default. + + @see AFURLConnectionOperation -shouldUseCredentialStorage + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; + +/** + The credential used by request operations for authentication challenges. + + @see AFURLConnectionOperation -credential + */ +@property (nonatomic, strong) NSURLCredential *credential; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created request operations to evaluate server trust for secure connections. `AFHTTPRequestOperationManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///------------------------------------ +/// @name Managing Network Reachability +///------------------------------------ + +/** + The network reachability manager. `AFHTTPRequestOperationManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for the `completionBlock` of request operations. If `NULL` (default), the main queue is used. + */ +@property (nonatomic, strong) dispatch_queue_t completionQueue; + +/** + The dispatch group for the `completionBlock` of request operations. If `NULL` (default), a private dispatch group is used. + */ +@property (nonatomic, strong) dispatch_group_t completionGroup; + +///--------------------------------------------- +/// @name Creating and Initializing HTTP Clients +///--------------------------------------------- + +/** + Creates and returns an `AFHTTPRequestOperationManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPRequestOperationManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(NSURL *)url; + +///--------------------------------------- +/// @name Managing HTTP Request Operations +///--------------------------------------- + +/** + Creates an `AFHTTPRequestOperation`, and sets the response serializers to that of the HTTP client. + + @param request The request object to be loaded asynchronously during execution of the operation. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. + */ +- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `AFHTTPRequestOperation` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes a single arguments: the request operation. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +@end + diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m new file mode 100644 index 0000000..4ae7275 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m @@ -0,0 +1,253 @@ +// AFHTTPRequestOperationManager.m +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import "AFHTTPRequestOperationManager.h" +#import "AFHTTPRequestOperation.h" + +#import +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +@interface AFHTTPRequestOperationManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPRequestOperationManager + ++ (instancetype)manager { + return [[self alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + self = [super init]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; + + self.operationQueue = [[NSOperationQueue alloc] init]; + + self.shouldUseCredentialStorage = YES; + + return self; +} + +#pragma mark - + +#ifdef _SYSTEMCONFIGURATION_H +#endif + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - + +- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + operation.responseSerializer = self.responseSerializer; + operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; + operation.credential = self.credential; + operation.securityPolicy = self.securityPolicy; + + [operation setCompletionBlockWithSuccess:success failure:failure]; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +#pragma mark - + +- (AFHTTPRequestOperation *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"GET" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"HEAD" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *requestOperation, __unused id responseObject) { + if (success) { + success(requestOperation); + } + } failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:nil]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"PUT" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"PATCH" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"DELETE" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectForKey:NSStringFromSelector(@selector(baseURL))]; + + self = [self initWithBaseURL:baseURL]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestOperationManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + + return HTTPClient; +} + +@end diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h new file mode 100644 index 0000000..8fed5a6 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1,240 @@ +// AFHTTPSessionManager.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import +#import + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +#import "AFURLSessionManager.h" + +/** + `AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths. + + ## Subclassing Notes + + Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. + + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. + + ## Methods to Override + + To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:completionHandler:`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + +@interface AFHTTPSessionManager : AFURLSessionManager + +/** + The URL used to monitor reachability, and construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong) NSURL *baseURL; + +/** + Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns an `AFHTTPSessionManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(NSURL *)url; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + @param configuration The configuration used to create the managed session. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(NSURL *)url + sessionConfiguration:(NSURLSessionConfiguration *)configuration; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `NSURLSessionDataTask` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +@end + +#endif diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m new file mode 100644 index 0000000..6413297 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m @@ -0,0 +1,321 @@ +// AFHTTPSessionManager.m +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFHTTPSessionManager.h" + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" + +#import +#import + +#ifdef _SYSTEMCONFIGURATION_H +#import +#import +#import +#import +#import +#endif + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +@interface AFHTTPSessionManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPSessionManager + ++ (instancetype)manager { + return [[[self class] alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + return [self initWithBaseURL:url sessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + return [self initWithBaseURL:nil sessionConfiguration:configuration]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url + sessionConfiguration:(NSURLSessionConfiguration *)configuration +{ + self = [super initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + return self; +} + +#pragma mark - + +#ifdef _SYSTEMCONFIGURATION_H +#endif + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [super setResponseSerializer:responseSerializer]; +} + +#pragma mark - + +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters success:^(NSURLSessionDataTask *task, __unused id responseObject) { + if (success) { + success(task); + } + } failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:nil completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(task, error); + } + } else { + if (success) { + success(task, responseObject); + } + } + }]; + + [task resume]; + + return task; +} + +- (NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *, id))success + failure:(void (^)(NSURLSessionDataTask *, NSError *))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *dataTask = nil; + dataTask = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(dataTask, error); + } + } else { + if (success) { + success(dataTask, responseObject); + } + } + }]; + + return dataTask; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))]; + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + if (!configuration) { + NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"]; + if (configurationIdentifier) { +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1100) + configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier]; +#else + configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier]; +#endif + } + } + + self = [self initWithBaseURL:baseURL sessionConfiguration:configuration]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; + } else { + [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"]; + } + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + + return HTTPClient; +} + +@end + +#endif diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h b/vendor/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h new file mode 100644 index 0000000..5e610d8 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1,193 @@ +// AFNetworkReachabilityManager.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { + AFNetworkReachabilityStatusUnknown = -1, + AFNetworkReachabilityStatusNotReachable = 0, + AFNetworkReachabilityStatusReachableViaWWAN = 1, + AFNetworkReachabilityStatusReachableViaWiFi = 2, +}; + +/** + `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + + Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability. + + See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/) + + @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. + */ +@interface AFNetworkReachabilityManager : NSObject + +/** + The current network reachability status. + */ +@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; + +/** + Whether or not the network is currently reachable. + */ +@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; + +/** + Whether or not the network is currently reachable via WWAN. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; + +/** + Whether or not the network is currently reachable via WiFi. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Returns the shared network reachability manager. + */ ++ (instancetype)sharedManager; + +/** + Creates and returns a network reachability manager for the specified domain. + + @param domain The domain used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified domain. + */ ++ (instancetype)managerForDomain:(NSString *)domain; + +/** + Creates and returns a network reachability manager for the socket address. + + @param address The socket address (`sockaddr_in`) used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified socket address. + */ ++ (instancetype)managerForAddress:(const void *)address; + +/** + Initializes an instance of a network reachability manager from the specified reachability object. + + @param reachability The reachability object to monitor. + + @return An initialized network reachability manager, actively monitoring the specified reachability. + */ +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability; + +///-------------------------------------------------- +/// @name Starting & Stopping Reachability Monitoring +///-------------------------------------------------- + +/** + Starts monitoring for changes in network reachability status. + */ +- (void)startMonitoring; + +/** + Stops monitoring for changes in network reachability status. + */ +- (void)stopMonitoring; + +///------------------------------------------------- +/// @name Getting Localized Reachability Description +///------------------------------------------------- + +/** + Returns a localized string representation of the current network reachability status. + */ +- (NSString *)localizedNetworkReachabilityStatusString; + +///--------------------------------------------------- +/// @name Setting Network Reachability Change Callback +///--------------------------------------------------- + +/** + Sets a callback to be executed when the network availability of the `baseURL` host changes. + + @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. + */ +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Network Reachability + + The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. + + enum { + AFNetworkReachabilityStatusUnknown, + AFNetworkReachabilityStatusNotReachable, + AFNetworkReachabilityStatusReachableViaWWAN, + AFNetworkReachabilityStatusReachableViaWiFi, + } + + `AFNetworkReachabilityStatusUnknown` + The `baseURL` host reachability is not known. + + `AFNetworkReachabilityStatusNotReachable` + The `baseURL` host cannot be reached. + + `AFNetworkReachabilityStatusReachableViaWWAN` + The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. + + `AFNetworkReachabilityStatusReachableViaWiFi` + The `baseURL` host can be reached via a Wi-Fi connection. + + ### Keys for Notification UserInfo Dictionary + + Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. + + `AFNetworkingReachabilityNotificationStatusItem` + A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. + The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. + */ + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when network reachability changes. + This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. + + @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). + */ +extern NSString * const AFNetworkingReachabilityDidChangeNotification; +extern NSString * const AFNetworkingReachabilityNotificationStatusItem; + +///-------------------- +/// @name Functions +///-------------------- + +/** + Returns a localized string representation of an `AFNetworkReachabilityStatus` value. + */ +extern NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m b/vendor/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m new file mode 100644 index 0000000..1da1482 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m @@ -0,0 +1,259 @@ +// AFNetworkReachabilityManager.m +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFNetworkReachabilityManager.h" + +#import +#import +#import +#import +#import + +NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; +NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; + +typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); + +typedef NS_ENUM(NSUInteger, AFNetworkReachabilityAssociation) { + AFNetworkReachabilityForAddress = 1, + AFNetworkReachabilityForAddressPair = 2, + AFNetworkReachabilityForName = 3, +}; + +NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { + switch (status) { + case AFNetworkReachabilityStatusNotReachable: + return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWWAN: + return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWiFi: + return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); + case AFNetworkReachabilityStatusUnknown: + default: + return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); + } +} + +static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { + BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); + BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); + BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); + BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); + BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); + + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; + if (isNetworkReachable == NO) { + status = AFNetworkReachabilityStatusNotReachable; + } +#if TARGET_OS_IPHONE + else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { + status = AFNetworkReachabilityStatusReachableViaWWAN; + } +#endif + else { + status = AFNetworkReachabilityStatusReachableViaWiFi; + } + + return status; +} + +static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + AFNetworkReachabilityStatusBlock block = (__bridge AFNetworkReachabilityStatusBlock)info; + if (block) { + block(status); + } + + + dispatch_async(dispatch_get_main_queue(), ^{ + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }]; + }); + +} + +static const void * AFNetworkReachabilityRetainCallback(const void *info) { + return Block_copy(info); +} + +static void AFNetworkReachabilityReleaseCallback(const void *info) { + if (info) { + Block_release(info); + } +} + +@interface AFNetworkReachabilityManager () +@property (readwrite, nonatomic, assign) SCNetworkReachabilityRef networkReachability; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityAssociation networkReachabilityAssociation; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; +@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; +@end + +@implementation AFNetworkReachabilityManager + ++ (instancetype)sharedManager { + static AFNetworkReachabilityManager *_sharedManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + struct sockaddr_in address; + bzero(&address, sizeof(address)); + address.sin_len = sizeof(address); + address.sin_family = AF_INET; + + _sharedManager = [self managerForAddress:&address]; + }); + + return _sharedManager; +} + ++ (instancetype)managerForDomain:(NSString *)domain { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); + + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + manager.networkReachabilityAssociation = AFNetworkReachabilityForName; + + return manager; +} + ++ (instancetype)managerForAddress:(const void *)address { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); + + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + manager.networkReachabilityAssociation = AFNetworkReachabilityForAddress; + + return manager; +} + +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { + self = [super init]; + if (!self) { + return nil; + } + + self.networkReachability = reachability; + self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; + + return self; +} + +- (void)dealloc { + [self stopMonitoring]; + + if (_networkReachability) { + CFRelease(_networkReachability); + _networkReachability = NULL; + } +} + +#pragma mark - + +- (BOOL)isReachable { + return [self isReachableViaWWAN] || [self isReachableViaWiFi]; +} + +- (BOOL)isReachableViaWWAN { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; +} + +- (BOOL)isReachableViaWiFi { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; +} + +#pragma mark - + +- (void)startMonitoring { + [self stopMonitoring]; + + if (!self.networkReachability) { + return; + } + + __weak __typeof(self)weakSelf = self; + AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + + strongSelf.networkReachabilityStatus = status; + if (strongSelf.networkReachabilityStatusBlock) { + strongSelf.networkReachabilityStatusBlock(status); + } + + }; + + SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; + SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); + SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); + + switch (self.networkReachabilityAssociation) { + case AFNetworkReachabilityForName: + break; + case AFNetworkReachabilityForAddress: + case AFNetworkReachabilityForAddressPair: + default: { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ + SCNetworkReachabilityFlags flags; + SCNetworkReachabilityGetFlags(self.networkReachability, &flags); + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + dispatch_async(dispatch_get_main_queue(), ^{ + callback(status); + + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }]; + + + }); + }); + } + break; + } +} + +- (void)stopMonitoring { + if (!self.networkReachability) { + return; + } + + SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); +} + +#pragma mark - + +- (NSString *)localizedNetworkReachabilityStatusString { + return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); +} + +#pragma mark - + +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { + self.networkReachabilityStatusBlock = block; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { + return [NSSet setWithObject:@"networkReachabilityStatus"]; + } + + return [super keyPathsForValuesAffectingValueForKey:key]; +} + +@end diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h b/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h new file mode 100644 index 0000000..68273da --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h @@ -0,0 +1,44 @@ +// AFNetworking.h +// +// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +#ifndef _AFNETWORKING_ + #define _AFNETWORKING_ + + #import "AFURLRequestSerialization.h" + #import "AFURLResponseSerialization.h" + #import "AFSecurityPolicy.h" + #import "AFNetworkReachabilityManager.h" + + #import "AFURLConnectionOperation.h" + #import "AFHTTPRequestOperation.h" + #import "AFHTTPRequestOperationManager.h" + +#if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \ + ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) ) + #import "AFURLSessionManager.h" + #import "AFHTTPSessionManager.h" +#endif + +#endif /* _AFNETWORKING_ */ diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h b/vendor/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h new file mode 100644 index 0000000..a880d75 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1,143 @@ +// AFSecurity.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, +}; + +/** + `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + + Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. + */ +@interface AFSecurityPolicy : NSObject + +/** + The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. + */ +@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; + +/** + Whether to evaluate an entire SSL certificate chain, or just the leaf certificate. Defaults to `YES`. + */ +@property (nonatomic, assign) BOOL validatesCertificateChain; + +/** + The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. + */ +@property (nonatomic, strong) NSArray *pinnedCertificates; + +/** + Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL allowInvalidCertificates; + +/** + Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES` for `AFSSLPinningModePublicKey` or `AFSSLPinningModeCertificate`, otherwise `NO`. + */ +@property (nonatomic, assign) BOOL validatesDomainName; + +///----------------------------------------- +/// @name Getting Specific Security Policies +///----------------------------------------- + +/** + Returns the shared default security policy, which does not allow invalid certificates, does not validate domain name, and does not validate against pinned certificates or public keys. + + @return The default security policy. + */ ++ (instancetype)defaultPolicy; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a security policy with the specified pinning mode. + + @param pinningMode The SSL pinning mode. + + @return A new security policy. + */ ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; + +///------------------------------ +/// @name Evaluating Server Trust +///------------------------------ + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + + @return Whether or not to trust the server. + + @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE; + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + @param domain The domain of serverTrust. If `nil`, the domain will not be validated. + + @return Whether or not to trust the server. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(NSString *)domain; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## SSL Pinning Modes + + The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. + + enum { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, + } + + `AFSSLPinningModeNone` + Do not used pinned certificates to validate servers. + + `AFSSLPinningModePublicKey` + Validate host certificates against public keys of pinned certificates. + + `AFSSLPinningModeCertificate` + Validate host certificates against pinned certificates. +*/ diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m b/vendor/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m new file mode 100644 index 0000000..1f97f91 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m @@ -0,0 +1,335 @@ +// AFSecurity.m +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFSecurityPolicy.h" + +// Equivalent of macro in , without causing compiler warning: +// "'DebugAssert' is deprecated: first deprecated in OS X 10.8" +#ifndef AF_Require + #define AF_Require(assertion, exceptionLabel) \ + do { \ + if (__builtin_expect(!(assertion), 0)) { \ + goto exceptionLabel; \ + } \ + } while (0) +#endif + +#ifndef AF_Require_noErr + #define AF_Require_noErr(errorCode, exceptionLabel) \ + do { \ + if (__builtin_expect(0 != (errorCode), 0)) { \ + goto exceptionLabel; \ + } \ + } while (0) +#endif + +#if !defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +static NSData * AFSecKeyGetData(SecKeyRef key) { + CFDataRef data = NULL; + + AF_Require_noErr(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out); + + return (__bridge_transfer NSData *)data; + +_out: + if (data) { + CFRelease(data); + } + + return nil; +} +#endif + +static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + return [(__bridge id)key1 isEqual:(__bridge id)key2]; +#else + return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)]; +#endif +} + +static id AFPublicKeyForCertificate(NSData *certificate) { + id allowedPublicKey = nil; + SecCertificateRef allowedCertificate; + SecCertificateRef allowedCertificates[1]; + CFArrayRef tempCertificates = nil; + SecPolicyRef policy = nil; + SecTrustRef allowedTrust = nil; + SecTrustResultType result; + + allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate); + AF_Require(allowedCertificate != NULL, _out); + + allowedCertificates[0] = allowedCertificate; + tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); + + policy = SecPolicyCreateBasicX509(); + AF_Require_noErr(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out); + AF_Require_noErr(SecTrustEvaluate(allowedTrust, &result), _out); + + allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); + +_out: + if (allowedTrust) { + CFRelease(allowedTrust); + } + + if (policy) { + CFRelease(policy); + } + + if (tempCertificates) { + CFRelease(tempCertificates); + } + + if (allowedCertificate) { + CFRelease(allowedCertificate); + } + + return allowedPublicKey; +} + +static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { + BOOL isValid = NO; + SecTrustResultType result; + AF_Require_noErr(SecTrustEvaluate(serverTrust, &result), _out); + + isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); + +_out: + return isValid; +} + +static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; + } + + return [NSArray arrayWithArray:trustChain]; +} + +static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { + SecPolicyRef policy = SecPolicyCreateBasicX509(); + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + + SecCertificateRef someCertificates[] = {certificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); + + SecTrustRef trust; + AF_Require_noErr(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); + + SecTrustResultType result; + AF_Require_noErr(SecTrustEvaluate(trust, &result), _out); + + [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; + + _out: + if (trust) { + CFRelease(trust); + } + + if (certificates) { + CFRelease(certificates); + } + + continue; + } + CFRelease(policy); + + return [NSArray arrayWithArray:trustChain]; +} + +#pragma mark - + +@interface AFSecurityPolicy() +@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode; +@property (readwrite, nonatomic, strong) NSArray *pinnedPublicKeys; +@end + +@implementation AFSecurityPolicy + ++ (NSArray *)defaultPinnedCertificates { + static NSArray *_defaultPinnedCertificates = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; + + NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; + for (NSString *path in paths) { + NSData *certificateData = [NSData dataWithContentsOfFile:path]; + [certificates addObject:certificateData]; + } + + _defaultPinnedCertificates = [[NSArray alloc] initWithArray:certificates]; + }); + + return _defaultPinnedCertificates; +} + ++ (instancetype)defaultPolicy { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = AFSSLPinningModeNone; + + return securityPolicy; +} + ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = pinningMode; + + [securityPolicy setPinnedCertificates:[self defaultPinnedCertificates]]; + + return securityPolicy; +} + +- (id)init { + self = [super init]; + if (!self) { + return nil; + } + + self.validatesCertificateChain = YES; + + return self; +} + +#pragma mark - + +- (void)setSSLPinningMode:(AFSSLPinningMode)SSLPinningMode { + _SSLPinningMode = SSLPinningMode; + + switch (self.SSLPinningMode) { + case AFSSLPinningModePublicKey: + case AFSSLPinningModeCertificate: + self.validatesDomainName = YES; + break; + default: + self.validatesDomainName = NO; + break; + } +} + +- (void)setPinnedCertificates:(NSArray *)pinnedCertificates { + _pinnedCertificates = pinnedCertificates; + + if (self.pinnedCertificates) { + NSMutableArray *mutablePinnedPublicKeys = [NSMutableArray arrayWithCapacity:[self.pinnedCertificates count]]; + for (NSData *certificate in self.pinnedCertificates) { + id publicKey = AFPublicKeyForCertificate(certificate); + if (!publicKey) { + continue; + } + [mutablePinnedPublicKeys addObject:publicKey]; + } + self.pinnedPublicKeys = [NSArray arrayWithArray:mutablePinnedPublicKeys]; + } else { + self.pinnedPublicKeys = nil; + } +} + +#pragma mark - + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust { + return [self evaluateServerTrust:serverTrust forDomain:nil]; +} + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(NSString *)domain +{ + NSMutableArray *policies = [NSMutableArray array]; + if (self.validatesDomainName) { + [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; + } else { + [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; + } + + SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); + + if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { + return NO; + } + + NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); + switch (self.SSLPinningMode) { + case AFSSLPinningModeNone: + return YES; + case AFSSLPinningModeCertificate: { + NSMutableArray *pinnedCertificates = [NSMutableArray array]; + for (NSData *certificateData in self.pinnedCertificates) { + [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; + } + SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); + + if (!AFServerTrustIsValid(serverTrust)) { + return NO; + } + + if (!self.validatesCertificateChain) { + return YES; + } + + NSUInteger trustedCertificateCount = 0; + for (NSData *trustChainCertificate in serverCertificates) { + if ([self.pinnedCertificates containsObject:trustChainCertificate]) { + trustedCertificateCount++; + } + } + + return trustedCertificateCount == [serverCertificates count]; + } + case AFSSLPinningModePublicKey: { + NSUInteger trustedPublicKeyCount = 0; + NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); + if (!self.validatesCertificateChain && [publicKeys count] > 0) { + publicKeys = @[[publicKeys firstObject]]; + } + + for (id trustChainPublicKey in publicKeys) { + for (id pinnedPublicKey in self.pinnedPublicKeys) { + if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { + trustedPublicKeyCount += 1; + } + } + } + + return trustedPublicKeyCount > 0 && ((self.validatesCertificateChain && trustedPublicKeyCount == [serverCertificates count]) || (!self.validatesCertificateChain && trustedPublicKeyCount >= 1)); + } + } + + return NO; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { + return [NSSet setWithObject:@"pinnedCertificates"]; +} + +@end diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h b/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h new file mode 100644 index 0000000..8543556 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h @@ -0,0 +1,328 @@ +// AFURLConnectionOperation.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" +#import "AFSecurityPolicy.h" + +/** + `AFURLConnectionOperation` is a subclass of `NSOperation` that implements `NSURLConnection` delegate methods. + + ## Subclassing Notes + + This is the base class of all network request operations. You may wish to create your own subclass in order to implement additional `NSURLConnection` delegate methods (see "`NSURLConnection` Delegate Methods" below), or to provide additional properties and/or class constructors. + + If you are creating a subclass that communicates over the HTTP or HTTPS protocols, you may want to consider subclassing `AFHTTPRequestOperation` instead, as it supports specifying acceptable content types or status codes. + + ## NSURLConnection Delegate Methods + + `AFURLConnectionOperation` implements the following `NSURLConnection` delegate methods: + + - `connection:didReceiveResponse:` + - `connection:didReceiveData:` + - `connectionDidFinishLoading:` + - `connection:didFailWithError:` + - `connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:` + - `connection:willCacheResponse:` + - `connectionShouldUseCredentialStorage:` + - `connection:needNewBodyStream:` + - `connection:willSendRequestForAuthenticationChallenge:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Callbacks and Completion Blocks + + The built-in `completionBlock` provided by `NSOperation` allows for custom behavior to be executed after the request finishes. It is a common pattern for class constructors in subclasses to take callback block parameters, and execute them conditionally in the body of its `completionBlock`. Make sure to handle cancelled operations appropriately when setting a `completionBlock` (i.e. returning early before parsing response data). See the implementation of any of the `AFHTTPRequestOperation` subclasses for an example of this. + + Subclasses are strongly discouraged from overriding `setCompletionBlock:`, as `AFURLConnectionOperation`'s implementation includes a workaround to mitigate retain cycles, and what Apple rather ominously refers to as ["The Deallocation Problem"](http://developer.apple.com/library/ios/#technotes/tn2109/). + + ## SSL Pinning + + Relying on the CA trust model to validate SSL certificates exposes your app to security vulnerabilities, such as man-in-the-middle attacks. For applications that connect to known servers, SSL certificate pinning provides an increased level of security, by checking server certificate validity against those specified in the app bundle. + + SSL with certificate pinning is strongly recommended for any application that transmits sensitive information to an external webservice. + + Connections will be validated on all matching certificates with a `.cer` extension in the bundle root. + + ## App Extensions + + When using AFNetworking in an App Extension, `#define AF_APP_EXTENSIONS` to avoid using unavailable APIs. + + ## NSCoding & NSCopying Conformance + + `AFURLConnectionOperation` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. However, because of the intrinsic limitations of capturing the exact state of an operation at a particular moment, there are some important caveats to keep in mind: + + ### NSCoding Caveats + + - Encoded operations do not include any block or stream properties. Be sure to set `completionBlock`, `outputStream`, and any callback blocks as necessary when using `-initWithCoder:` or `NSKeyedUnarchiver`. + - Operations are paused on `encodeWithCoder:`. If the operation was encoded while paused or still executing, its archived state will return `YES` for `isReady`. Otherwise, the state of an operation when encoding will remain unchanged. + + ### NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new operation with the `NSURLRequest` of the original. So rather than an exact copy of the operation at that particular instant, the copying mechanism returns a completely new instance, which can be useful for retrying operations. + - A copy of an operation will not include the `outputStream` of the original. + - Operation copies do not include `completionBlock`, as it often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. + */ + +@interface AFURLConnectionOperation : NSOperation + +///------------------------------- +/// @name Accessing Run Loop Modes +///------------------------------- + +/** + The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing `NSRunLoopCommonModes`. + */ +@property (nonatomic, strong) NSSet *runLoopModes; + +///----------------------------------------- +/// @name Getting URL Connection Information +///----------------------------------------- + +/** + The request used by the operation's connection. + */ +@property (readonly, nonatomic, strong) NSURLRequest *request; + +/** + The last response received by the operation's connection. + */ +@property (readonly, nonatomic, strong) NSURLResponse *response; + +/** + The error, if any, that occurred in the lifecycle of the request. + */ +@property (readonly, nonatomic, strong) NSError *error; + +///---------------------------- +/// @name Getting Response Data +///---------------------------- + +/** + The data received during the request. + */ +@property (readonly, nonatomic, strong) NSData *responseData; + +/** + The string representation of the response data. + */ +@property (readonly, nonatomic, copy) NSString *responseString; + +/** + The string encoding of the response. + + If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. + */ +@property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; + +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. + + This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; + +/** + The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. + + This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. + */ +@property (nonatomic, strong) NSURLCredential *credential; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used to evaluate server trust for secure connections. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///------------------------ +/// @name Accessing Streams +///------------------------ + +/** + The input stream used to read data to be sent during the request. + + This property acts as a proxy to the `HTTPBodyStream` property of `request`. + */ +@property (nonatomic, strong) NSInputStream *inputStream; + +/** + The output stream that is used to write data received until the request is finished. + + By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request, with the intermediary `outputStream` property set to `nil`. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. + */ +@property (nonatomic, strong) NSOutputStream *outputStream; + +///--------------------------------- +/// @name Managing Callback Queues +///--------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +@property (nonatomic, strong) dispatch_queue_t completionQueue; + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +@property (nonatomic, strong) dispatch_group_t completionGroup; + +///--------------------------------------------- +/// @name Managing Request Operation Information +///--------------------------------------------- + +/** + The user info dictionary for the receiver. + */ +@property (nonatomic, strong) NSDictionary *userInfo; + +///------------------------------------------------------ +/// @name Initializing an AFURLConnectionOperation Object +///------------------------------------------------------ + +/** + Initializes and returns a newly allocated operation object with a url connection configured with the specified url request. + + This is the designated initializer. + + @param urlRequest The request object to be used by the operation connection. + */ +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest; + +///---------------------------------- +/// @name Pausing / Resuming Requests +///---------------------------------- + +/** + Pauses the execution of the request operation. + + A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. + */ +- (void)pause; + +/** + Whether the request operation is currently paused. + + @return `YES` if the operation is currently paused, otherwise `NO`. + */ +- (BOOL)isPaused; + +/** + Resumes the execution of the paused request operation. + + Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. + */ +- (void)resume; + +///---------------------------------------------- +/// @name Configuring Backgrounding Task Behavior +///---------------------------------------------- + +/** + Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task. + + @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified. + */ +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) +- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler; +#endif + +///--------------------------------- +/// @name Setting Progress Callbacks +///--------------------------------- + +/** + Sets a callback to be called when an undetermined number of bytes have been uploaded to the server. + + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block; + +/** + Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block; + +///------------------------------------------------- +/// @name Setting NSURLConnection Delegate Callbacks +///------------------------------------------------- + +/** + Sets a block to be executed when the connection will authenticate a challenge in order to download its request, as handled by the `NSURLConnectionDelegate` method `connection:willSendRequestForAuthenticationChallenge:`. + + @param block A block object to be executed when the connection will authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. This block must invoke one of the challenge-responder methods (NSURLAuthenticationChallengeSender protocol). + + If `allowsInvalidSSLCertificate` is set to YES, `connection:willSendRequestForAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. + */ +- (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; + +/** + Sets a block to be executed when the server redirects the request from one URL to another URL, or when the request URL changed by the `NSURLProtocol` subclass handling the request in order to standardize its format, as handled by the `NSURLConnectionDataDelegate` method `connection:willSendRequest:redirectResponse:`. + + @param block A block object to be executed when the request URL was changed. The block returns an `NSURLRequest` object, the URL request to redirect, and takes three arguments: the URL connection object, the the proposed redirected request, and the URL response that caused the redirect. + */ +- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block; + + +/** + Sets a block to be executed to modify the response a connection will cache, if any, as handled by the `NSURLConnectionDelegate` method `connection:willCacheResponse:`. + + @param block A block object to be executed to determine what response a connection will cache, if any. The block returns an `NSCachedURLResponse` object, the cached response to store in memory or `nil` to prevent the response from being cached, and takes two arguments: the URL connection object, and the cached response provided for the request. + */ +- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block; + +/// + +/** + + */ ++ (NSArray *)batchOfRequestOperations:(NSArray *)operations + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(void (^)(NSArray *operations))completionBlock; + +@end + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when an operation begins executing. + */ +extern NSString * const AFNetworkingOperationDidStartNotification; + +/** + Posted when an operation finishes. + */ +extern NSString * const AFNetworkingOperationDidFinishNotification; diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m b/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m new file mode 100644 index 0000000..cfe609a --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m @@ -0,0 +1,789 @@ +// AFURLConnectionOperation.m +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLConnectionOperation.h" + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +#if !__has_feature(objc_arc) +#error AFNetworking must be built with ARC. +// You can turn on ARC for only AFNetworking files by adding -fobjc-arc to the build phase for each of its files. +#endif + +typedef NS_ENUM(NSInteger, AFOperationState) { + AFOperationPausedState = -1, + AFOperationReadyState = 1, + AFOperationExecutingState = 2, + AFOperationFinishedState = 3, +}; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) +typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier; +#else +typedef id AFBackgroundTaskIdentifier; +#endif + +static dispatch_group_t url_request_operation_completion_group() { + static dispatch_group_t af_url_request_operation_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_request_operation_completion_group = dispatch_group_create(); + }); + + return af_url_request_operation_completion_group; +} + +static dispatch_queue_t url_request_operation_completion_queue() { + static dispatch_queue_t af_url_request_operation_completion_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_request_operation_completion_queue = dispatch_queue_create("com.alamofire.networking.operation.queue", DISPATCH_QUEUE_CONCURRENT ); + }); + + return af_url_request_operation_completion_queue; +} + +static NSString * const kAFNetworkingLockName = @"com.alamofire.networking.operation.lock"; + +NSString * const AFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start"; +NSString * const AFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish"; + +typedef void (^AFURLConnectionOperationProgressBlock)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); +typedef void (^AFURLConnectionOperationAuthenticationChallengeBlock)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge); +typedef NSCachedURLResponse * (^AFURLConnectionOperationCacheResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse); +typedef NSURLRequest * (^AFURLConnectionOperationRedirectResponseBlock)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse); + +static inline NSString * AFKeyPathFromOperationState(AFOperationState state) { + switch (state) { + case AFOperationReadyState: + return @"isReady"; + case AFOperationExecutingState: + return @"isExecuting"; + case AFOperationFinishedState: + return @"isFinished"; + case AFOperationPausedState: + return @"isPaused"; + default: { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" + return @"state"; +#pragma clang diagnostic pop + } + } +} + +static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperationState toState, BOOL isCancelled) { + switch (fromState) { + case AFOperationReadyState: + switch (toState) { + case AFOperationPausedState: + case AFOperationExecutingState: + return YES; + case AFOperationFinishedState: + return isCancelled; + default: + return NO; + } + case AFOperationExecutingState: + switch (toState) { + case AFOperationPausedState: + case AFOperationFinishedState: + return YES; + default: + return NO; + } + case AFOperationFinishedState: + return NO; + case AFOperationPausedState: + return toState == AFOperationReadyState; + default: { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" + switch (toState) { + case AFOperationPausedState: + case AFOperationReadyState: + case AFOperationExecutingState: + case AFOperationFinishedState: + return YES; + default: + return NO; + } + } +#pragma clang diagnostic pop + } +} + +@interface AFURLConnectionOperation () +@property (readwrite, nonatomic, assign) AFOperationState state; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; +@property (readwrite, nonatomic, strong) NSURLConnection *connection; +@property (readwrite, nonatomic, strong) NSURLRequest *request; +@property (readwrite, nonatomic, strong) NSURLResponse *response; +@property (readwrite, nonatomic, strong) NSError *error; +@property (readwrite, nonatomic, strong) NSData *responseData; +@property (readwrite, nonatomic, copy) NSString *responseString; +@property (readwrite, nonatomic, assign) NSStringEncoding responseStringEncoding; +@property (readwrite, nonatomic, assign) long long totalBytesRead; +@property (readwrite, nonatomic, assign) AFBackgroundTaskIdentifier backgroundTaskIdentifier; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationChallengeBlock authenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationCacheResponseBlock cacheResponse; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationRedirectResponseBlock redirectResponse; + +- (void)operationDidStart; +- (void)finish; +- (void)cancelConnection; +@end + +@implementation AFURLConnectionOperation +@synthesize outputStream = _outputStream; + ++ (void)networkRequestThreadEntryPoint:(id)__unused object { + @autoreleasepool { + [[NSThread currentThread] setName:@"AFNetworking"]; + + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + [runLoop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode]; + [runLoop run]; + } +} + ++ (NSThread *)networkRequestThread { + static NSThread *_networkRequestThread = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _networkRequestThread = [[NSThread alloc] initWithTarget:self selector:@selector(networkRequestThreadEntryPoint:) object:nil]; + [_networkRequestThread start]; + }); + + return _networkRequestThread; +} + +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { + NSParameterAssert(urlRequest); + + self = [super init]; + if (!self) { + return nil; + } + + _state = AFOperationReadyState; + + self.lock = [[NSRecursiveLock alloc] init]; + self.lock.name = kAFNetworkingLockName; + + self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; + + self.request = urlRequest; + + self.shouldUseCredentialStorage = YES; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + + return self; +} + +- (void)dealloc { + if (_outputStream) { + [_outputStream close]; + _outputStream = nil; + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) + if (_backgroundTaskIdentifier) { + [[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier]; + _backgroundTaskIdentifier = UIBackgroundTaskInvalid; + } +#endif +} + +#pragma mark - + +- (void)setResponseData:(NSData *)responseData { + [self.lock lock]; + if (!responseData) { + _responseData = nil; + } else { + _responseData = [NSData dataWithBytes:responseData.bytes length:responseData.length]; + } + [self.lock unlock]; +} + +- (NSString *)responseString { + [self.lock lock]; + if (!_responseString && self.response && self.responseData) { + self.responseString = [[NSString alloc] initWithData:self.responseData encoding:self.responseStringEncoding]; + } + [self.lock unlock]; + + return _responseString; +} + +- (NSStringEncoding)responseStringEncoding { + [self.lock lock]; + if (!_responseStringEncoding && self.response) { + NSStringEncoding stringEncoding = NSUTF8StringEncoding; + if (self.response.textEncodingName) { + CFStringEncoding IANAEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName); + if (IANAEncoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(IANAEncoding); + } + } + + self.responseStringEncoding = stringEncoding; + } + [self.lock unlock]; + + return _responseStringEncoding; +} + +- (NSInputStream *)inputStream { + return self.request.HTTPBodyStream; +} + +- (void)setInputStream:(NSInputStream *)inputStream { + NSMutableURLRequest *mutableRequest = [self.request mutableCopy]; + mutableRequest.HTTPBodyStream = inputStream; + self.request = mutableRequest; +} + +- (NSOutputStream *)outputStream { + if (!_outputStream) { + self.outputStream = [NSOutputStream outputStreamToMemory]; + } + + return _outputStream; +} + +- (void)setOutputStream:(NSOutputStream *)outputStream { + [self.lock lock]; + if (outputStream != _outputStream) { + if (_outputStream) { + [_outputStream close]; + } + + _outputStream = outputStream; + } + [self.lock unlock]; +} + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) +- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler { + [self.lock lock]; + if (!self.backgroundTaskIdentifier) { + UIApplication *application = [UIApplication sharedApplication]; + __weak __typeof(self)weakSelf = self; + self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ + __strong __typeof(weakSelf)strongSelf = weakSelf; + + if (handler) { + handler(); + } + + if (strongSelf) { + [strongSelf cancel]; + + [application endBackgroundTask:strongSelf.backgroundTaskIdentifier]; + strongSelf.backgroundTaskIdentifier = UIBackgroundTaskInvalid; + } + }]; + } + [self.lock unlock]; +} +#endif + +#pragma mark - + +- (void)setState:(AFOperationState)state { + if (!AFStateTransitionIsValid(self.state, state, [self isCancelled])) { + return; + } + + [self.lock lock]; + NSString *oldStateKey = AFKeyPathFromOperationState(self.state); + NSString *newStateKey = AFKeyPathFromOperationState(state); + + [self willChangeValueForKey:newStateKey]; + [self willChangeValueForKey:oldStateKey]; + _state = state; + [self didChangeValueForKey:oldStateKey]; + [self didChangeValueForKey:newStateKey]; + [self.lock unlock]; +} + +- (void)pause { + if ([self isPaused] || [self isFinished] || [self isCancelled]) { + return; + } + + [self.lock lock]; + if ([self isExecuting]) { + [self performSelector:@selector(operationDidPause) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + + dispatch_async(dispatch_get_main_queue(), ^{ + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + }); + } + + self.state = AFOperationPausedState; + [self.lock unlock]; +} + +- (void)operationDidPause { + [self.lock lock]; + [self.connection cancel]; + [self.lock unlock]; +} + +- (BOOL)isPaused { + return self.state == AFOperationPausedState; +} + +- (void)resume { + if (![self isPaused]) { + return; + } + + [self.lock lock]; + self.state = AFOperationReadyState; + + [self start]; + [self.lock unlock]; +} + +#pragma mark - + +- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block { + self.uploadProgress = block; +} + +- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block { + self.downloadProgress = block; +} + +- (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block { + self.authenticationChallenge = block; +} + +- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block { + self.cacheResponse = block; +} + +- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block { + self.redirectResponse = block; +} + +#pragma mark - NSOperation + +- (void)setCompletionBlock:(void (^)(void))block { + [self.lock lock]; + if (!block) { + [super setCompletionBlock:nil]; + } else { + __weak __typeof(self)weakSelf = self; + [super setCompletionBlock:^ { + __strong __typeof(weakSelf)strongSelf = weakSelf; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_group_t group = strongSelf.completionGroup ?: url_request_operation_completion_group(); + dispatch_queue_t queue = strongSelf.completionQueue ?: dispatch_get_main_queue(); +#pragma clang diagnostic pop + + dispatch_group_async(group, queue, ^{ + block(); + }); + + dispatch_group_notify(group, url_request_operation_completion_queue(), ^{ + [strongSelf setCompletionBlock:nil]; + }); + }]; + } + [self.lock unlock]; +} + +- (BOOL)isReady { + return self.state == AFOperationReadyState && [super isReady]; +} + +- (BOOL)isExecuting { + return self.state == AFOperationExecutingState; +} + +- (BOOL)isFinished { + return self.state == AFOperationFinishedState; +} + +- (BOOL)isConcurrent { + return YES; +} + +- (void)start { + [self.lock lock]; + if ([self isCancelled]) { + [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } else if ([self isReady]) { + self.state = AFOperationExecutingState; + + [self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } + [self.lock unlock]; +} + +- (void)operationDidStart { + [self.lock lock]; + if (![self isCancelled]) { + self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; + + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + for (NSString *runLoopMode in self.runLoopModes) { + [self.connection scheduleInRunLoop:runLoop forMode:runLoopMode]; + [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode]; + } + + [self.outputStream open]; + [self.connection start]; + } + [self.lock unlock]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + }); +} + +- (void)finish { + [self.lock lock]; + self.state = AFOperationFinishedState; + [self.lock unlock]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + }); +} + +- (void)cancel { + [self.lock lock]; + if (![self isFinished] && ![self isCancelled]) { + [super cancel]; + + if ([self isExecuting]) { + [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } + } + [self.lock unlock]; +} + +- (void)cancelConnection { + NSDictionary *userInfo = nil; + if ([self.request URL]) { + userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; + } + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; + + if (![self isFinished]) { + if (self.connection) { + [self.connection cancel]; + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:error]; + } else { + // Accomodate race condition where `self.connection` has not yet been set before cancellation + self.error = error; + [self finish]; + } + } +} + +#pragma mark - + ++ (NSArray *)batchOfRequestOperations:(NSArray *)operations + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(void (^)(NSArray *operations))completionBlock +{ + if (!operations || [operations count] == 0) { + return @[[NSBlockOperation blockOperationWithBlock:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(@[]); + } + }); + }]]; + } + + __block dispatch_group_t group = dispatch_group_create(); + NSBlockOperation *batchedOperation = [NSBlockOperation blockOperationWithBlock:^{ + dispatch_group_notify(group, dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(operations); + } + }); + }]; + + for (AFURLConnectionOperation *operation in operations) { + operation.completionGroup = group; + void (^originalCompletionBlock)(void) = [operation.completionBlock copy]; + __weak __typeof(operation)weakOperation = operation; + operation.completionBlock = ^{ + __strong __typeof(weakOperation)strongOperation = weakOperation; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_queue_t queue = strongOperation.completionQueue ?: dispatch_get_main_queue(); +#pragma clang diagnostic pop + dispatch_group_async(group, queue, ^{ + if (originalCompletionBlock) { + originalCompletionBlock(); + } + + NSUInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger __unused idx, BOOL __unused *stop) { + return [op isFinished]; + }] count]; + + if (progressBlock) { + progressBlock(numberOfFinishedOperations, [operations count]); + } + + dispatch_group_leave(group); + }); + }; + + dispatch_group_enter(group); + [batchedOperation addDependency:operation]; + } + + return [operations arrayByAddingObject:batchedOperation]; +} + +#pragma mark - NSObject + +- (NSString *)description { + [self.lock lock]; + NSString *description = [NSString stringWithFormat:@"<%@: %p, state: %@, cancelled: %@ request: %@, response: %@>", NSStringFromClass([self class]), self, AFKeyPathFromOperationState(self.state), ([self isCancelled] ? @"YES" : @"NO"), self.request, self.response]; + [self.lock unlock]; + return description; +} + +#pragma mark - NSURLConnectionDelegate + +- (void)connection:(NSURLConnection *)connection +willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge +{ + if (self.authenticationChallenge) { + self.authenticationChallenge(connection, challenge); + return; + } + + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } + } else { + if ([challenge previousFailureCount] == 0) { + if (self.credential) { + [[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } +} + +- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { + return self.shouldUseCredentialStorage; +} + +- (NSURLRequest *)connection:(NSURLConnection *)connection + willSendRequest:(NSURLRequest *)request + redirectResponse:(NSURLResponse *)redirectResponse +{ + if (self.redirectResponse) { + return self.redirectResponse(connection, request, redirectResponse); + } else { + return request; + } +} + +- (void)connection:(NSURLConnection __unused *)connection + didSendBodyData:(NSInteger)bytesWritten + totalBytesWritten:(NSInteger)totalBytesWritten +totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite +{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.uploadProgress) { + self.uploadProgress((NSUInteger)bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } + }); +} + +- (void)connection:(NSURLConnection __unused *)connection +didReceiveResponse:(NSURLResponse *)response +{ + self.response = response; +} + +- (void)connection:(NSURLConnection __unused *)connection + didReceiveData:(NSData *)data +{ + NSUInteger length = [data length]; + while (YES) { + NSInteger totalNumberOfBytesWritten = 0; + if ([self.outputStream hasSpaceAvailable]) { + const uint8_t *dataBuffer = (uint8_t *)[data bytes]; + + NSInteger numberOfBytesWritten = 0; + while (totalNumberOfBytesWritten < (NSInteger)length) { + numberOfBytesWritten = [self.outputStream write:&dataBuffer[(NSUInteger)totalNumberOfBytesWritten] maxLength:(length - (NSUInteger)totalNumberOfBytesWritten)]; + if (numberOfBytesWritten == -1) { + break; + } + + totalNumberOfBytesWritten += numberOfBytesWritten; + } + + break; + } + + if (self.outputStream.streamError) { + [self.connection cancel]; + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.outputStream.streamError]; + return; + } + } + + dispatch_async(dispatch_get_main_queue(), ^{ + self.totalBytesRead += (long long)length; + + if (self.downloadProgress) { + self.downloadProgress(length, self.totalBytesRead, self.response.expectedContentLength); + } + }); +} + +- (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection { + self.responseData = [self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey]; + + [self.outputStream close]; + if (self.responseData) { + self.outputStream = nil; + } + + self.connection = nil; + + [self finish]; +} + +- (void)connection:(NSURLConnection __unused *)connection + didFailWithError:(NSError *)error +{ + self.error = error; + + [self.outputStream close]; + if (self.responseData) { + self.outputStream = nil; + } + + self.connection = nil; + + [self finish]; +} + +- (NSCachedURLResponse *)connection:(NSURLConnection *)connection + willCacheResponse:(NSCachedURLResponse *)cachedResponse +{ + if (self.cacheResponse) { + return self.cacheResponse(connection, cachedResponse); + } else { + if ([self isCancelled]) { + return nil; + } + + return cachedResponse; + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURLRequest *request = [decoder decodeObjectOfClass:[NSURLRequest class] forKey:NSStringFromSelector(@selector(request))]; + + self = [self initWithRequest:request]; + if (!self) { + return nil; + } + + self.state = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(state))] integerValue]; + self.response = [decoder decodeObjectOfClass:[NSHTTPURLResponse class] forKey:NSStringFromSelector(@selector(response))]; + self.error = [decoder decodeObjectOfClass:[NSError class] forKey:NSStringFromSelector(@selector(error))]; + self.responseData = [decoder decodeObjectOfClass:[NSData class] forKey:NSStringFromSelector(@selector(responseData))]; + self.totalBytesRead = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(totalBytesRead))] longLongValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [self pause]; + + [coder encodeObject:self.request forKey:NSStringFromSelector(@selector(request))]; + + switch (self.state) { + case AFOperationExecutingState: + case AFOperationPausedState: + [coder encodeInteger:AFOperationReadyState forKey:NSStringFromSelector(@selector(state))]; + break; + default: + [coder encodeInteger:self.state forKey:NSStringFromSelector(@selector(state))]; + break; + } + + [coder encodeObject:self.response forKey:NSStringFromSelector(@selector(response))]; + [coder encodeObject:self.error forKey:NSStringFromSelector(@selector(error))]; + [coder encodeObject:self.responseData forKey:NSStringFromSelector(@selector(responseData))]; + [coder encodeInt64:self.totalBytesRead forKey:NSStringFromSelector(@selector(totalBytesRead))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFURLConnectionOperation *operation = [(AFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request]; + + operation.uploadProgress = self.uploadProgress; + operation.downloadProgress = self.downloadProgress; + operation.authenticationChallenge = self.authenticationChallenge; + operation.cacheResponse = self.cacheResponse; + operation.redirectResponse = self.redirectResponse; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +@end diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h b/vendor/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h new file mode 100644 index 0000000..aed4549 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1,463 @@ +// AFSerialization.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +/** + The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary. + + For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`. + */ +@protocol AFURLRequestSerialization + +/** + Returns a request with the specified parameters encoded into a copy of the original request. + + @param request The original request. + @param parameters The parameters to be encoded. + @param error The error that occurred while attempting to encode the request parameters. + + @return A serialized request. + */ +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError * __autoreleasing *)error; + +@end + +#pragma mark - + +/** + + */ +typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) { + AFHTTPRequestQueryStringDefaultStyle = 0, +}; + +@protocol AFMultipartFormData; + +/** + `AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPRequestSerializer : NSObject + +/** + The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Whether created requests can use the device’s cellular radio (if present). `YES` by default. + + @see NSMutableURLRequest -setAllowsCellularAccess: + */ +@property (nonatomic, assign) BOOL allowsCellularAccess; + +/** + The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default. + + @see NSMutableURLRequest -setCachePolicy: + */ +@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy; + +/** + Whether created requests should use the default cookie handling. `YES` by default. + + @see NSMutableURLRequest -setHTTPShouldHandleCookies: + */ +@property (nonatomic, assign) BOOL HTTPShouldHandleCookies; + +/** + Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default + + @see NSMutableURLRequest -setHTTPShouldUsePipelining: + */ +@property (nonatomic, assign) BOOL HTTPShouldUsePipelining; + +/** + The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default. + + @see NSMutableURLRequest -setNetworkServiceType: + */ +@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType; + +/** + The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds. + + @see NSMutableURLRequest -setTimeoutInterval: + */ +@property (nonatomic, assign) NSTimeInterval timeoutInterval; + +///--------------------------------------- +/// @name Configuring HTTP Request Headers +///--------------------------------------- + +/** + Default HTTP header field values to be applied to serialized requests. + */ +@property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +/** + Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header. + + @param field The HTTP header to set a default value for + @param value The value set as default for the specified header, or `nil` + */ +- (void)setValue:(NSString *)value +forHTTPHeaderField:(NSString *)field; + +/** + Returns the value for the HTTP headers set in the request serializer. + + @param field The HTTP header to retrieve the default value for + + @return The value set as default for the specified header, or `nil` + */ +- (NSString *)valueForHTTPHeaderField:(NSString *)field; + +/** + Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header. + + @param username The HTTP basic auth username + @param password The HTTP basic auth password + */ +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password; + +/** + @deprecated This method has been deprecated. Use -setValue:forHTTPHeaderField: instead. + */ +- (void)setAuthorizationHeaderFieldWithToken:(NSString *)token DEPRECATED_ATTRIBUTE; + + +/** + Clears any existing value for the "Authorization" HTTP header. + */ +- (void)clearAuthorizationHeader; + +///------------------------------------------------------- +/// @name Configuring Query String Parameter Serialization +///------------------------------------------------------- + +/** + HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default. + */ +@property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI; + +/** + Set the method of query string serialization according to one of the pre-defined styles. + + @param style The serialization style. + + @see AFHTTPRequestQueryStringSerializationStyle + */ +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style; + +/** + Set the a custom method of query string serialization according to the specified block. + + @param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request. + */ +- (void)setQueryStringSerializationWithBlock:(NSString * (^)(NSURLRequest *request, NSDictionary *parameters, NSError * __autoreleasing *error))block; + +///------------------------------- +/// @name Creating Request Objects +///------------------------------- + +/** + @deprecated This method has been deprecated. Use -requestWithMethod:URLString:parameters:error: instead. + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters DEPRECATED_ATTRIBUTE; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string. + + If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body. + + @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body. + @param error The error that occured while constructing the request. + + @return An `NSMutableURLRequest` object. + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + error:(NSError * __autoreleasing *)error; + +/** + @deprecated This method has been deprecated. Use -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error: instead. + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block DEPRECATED_ATTRIBUTE; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 + + Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. + + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded and set in the request HTTP body. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param error The error that occured while constructing the request. + + @return An `NSMutableURLRequest` object + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block + error:(NSError * __autoreleasing *)error; + +/** + Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished. + + @param request The multipart form request. + @param fileURL The file URL to write multipart form contents to. + @param handler A handler block to execute. + + @discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request. + + @see https://github.com/AFNetworking/AFNetworking/issues/1398 + */ +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(void (^)(NSError *error))handler; + +@end + +#pragma mark - + +/** + The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`. + */ +@protocol AFMultipartFormData + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. + + The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended, otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`. + @param mimeType The declared MIME type of the file data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. + + @param inputStream The input stream to be appended to the form data + @param name The name to be associated with the specified input stream. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. + @param length The length of the specified input stream in bytes. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified data. This parameter must not be `nil`. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + */ + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name; + + +/** + Appends HTTP headers, followed by the encoded data and the multipart form boundary. + + @param headers The HTTP headers to be appended to the form data. + @param body The data to be encoded and appended to the form data. This parameter must not be `nil`. + */ +- (void)appendPartWithHeaders:(NSDictionary *)headers + body:(NSData *)body; + +/** + Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. + + When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. + + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb. + @param delay Duration of delay each time a packet is read. By default, no delay is set. + */ +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay; + +@end + +#pragma mark - + +/** + `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`. + */ +@interface AFJSONRequestSerializer : AFHTTPRequestSerializer + +/** + Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONWritingOptions writingOptions; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param writingOptions The specified JSON writing options. + */ ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions; + +@end + +#pragma mark - + +/** + `AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`. + */ +@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + @warning The `writeOptions` property is currently unused. + */ +@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param writeOptions The property list write options. + + @warning The `writeOptions` property is currently unused. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions; + +@end + +#pragma mark - + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLRequestSerializationErrorDomain` + + ### Constants + + `AFURLRequestSerializationErrorDomain` + AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +extern NSString * const AFURLRequestSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLRequestErrorKey` + The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`. + */ +extern NSString * const AFNetworkingOperationFailingURLRequestErrorKey; + +/** + ## Throttling Bandwidth for HTTP Request Input Streams + + @see -throttleBandwidthWithPacketSize:delay: + + ### Constants + + `kAFUploadStream3GSuggestedPacketSize` + Maximum packet size, in number of bytes. Equal to 16kb. + + `kAFUploadStream3GSuggestedDelay` + Duration of delay each time a packet is read. Equal to 0.2 seconds. + */ +extern NSUInteger const kAFUploadStream3GSuggestedPacketSize; +extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m b/vendor/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m new file mode 100644 index 0000000..a56e854 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m @@ -0,0 +1,1339 @@ +// AFSerialization.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLRequestSerialization.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request"; +NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response"; + +typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, NSDictionary *parameters, NSError *__autoreleasing *error); + +static NSString * AFBase64EncodedStringFromString(NSString *string) { + NSData *data = [NSData dataWithBytes:[string UTF8String] length:[string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]]; + NSUInteger length = [data length]; + NSMutableData *mutableData = [NSMutableData dataWithLength:((length + 2) / 3) * 4]; + + uint8_t *input = (uint8_t *)[data bytes]; + uint8_t *output = (uint8_t *)[mutableData mutableBytes]; + + for (NSUInteger i = 0; i < length; i += 3) { + NSUInteger value = 0; + for (NSUInteger j = i; j < (i + 3); j++) { + value <<= 8; + if (j < length) { + value |= (0xFF & input[j]); + } + } + + static uint8_t const kAFBase64EncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + NSUInteger idx = (i / 3) * 4; + output[idx + 0] = kAFBase64EncodingTable[(value >> 18) & 0x3F]; + output[idx + 1] = kAFBase64EncodingTable[(value >> 12) & 0x3F]; + output[idx + 2] = (i + 1) < length ? kAFBase64EncodingTable[(value >> 6) & 0x3F] : '='; + output[idx + 3] = (i + 2) < length ? kAFBase64EncodingTable[(value >> 0) & 0x3F] : '='; + } + + return [[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding]; +} + +static NSString * const kAFCharactersToBeEscapedInQueryString = @":/?&=;+!@#$()',*"; + +static NSString * AFPercentEscapedQueryStringKeyFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { + static NSString * const kAFCharactersToLeaveUnescapedInQueryStringPairKey = @"[]."; + + return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)kAFCharactersToLeaveUnescapedInQueryStringPairKey, (__bridge CFStringRef)kAFCharactersToBeEscapedInQueryString, CFStringConvertNSStringEncodingToEncoding(encoding)); +} + +static NSString * AFPercentEscapedQueryStringValueFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { + return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, NULL, (__bridge CFStringRef)kAFCharactersToBeEscapedInQueryString, CFStringConvertNSStringEncodingToEncoding(encoding)); +} + +#pragma mark - + +@interface AFQueryStringPair : NSObject +@property (readwrite, nonatomic, strong) id field; +@property (readwrite, nonatomic, strong) id value; + +- (id)initWithField:(id)field value:(id)value; + +- (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding; +@end + +@implementation AFQueryStringPair + +- (id)initWithField:(id)field value:(id)value { + self = [super init]; + if (!self) { + return nil; + } + + self.field = field; + self.value = value; + + return self; +} + +- (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding { + if (!self.value || [self.value isEqual:[NSNull null]]) { + return AFPercentEscapedQueryStringKeyFromStringWithEncoding([self.field description], stringEncoding); + } else { + return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedQueryStringKeyFromStringWithEncoding([self.field description], stringEncoding), AFPercentEscapedQueryStringValueFromStringWithEncoding([self.value description], stringEncoding)]; + } +} + +@end + +#pragma mark - + +extern NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary); +extern NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value); + +static NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding stringEncoding) { + NSMutableArray *mutablePairs = [NSMutableArray array]; + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + [mutablePairs addObject:[pair URLEncodedStringValueWithEncoding:stringEncoding]]; + } + + return [mutablePairs componentsJoinedByString:@"&"]; +} + +NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary) { + return AFQueryStringPairsFromKeyAndValue(nil, dictionary); +} + +NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { + NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; + + NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)]; + + if ([value isKindOfClass:[NSDictionary class]]) { + NSDictionary *dictionary = value; + // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + id nestedValue = [dictionary objectForKey:nestedKey]; + if (nestedValue) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; + } + } + } else if ([value isKindOfClass:[NSArray class]]) { + NSArray *array = value; + for (id nestedValue in array) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; + } + } else if ([value isKindOfClass:[NSSet class]]) { + NSSet *set = value; + for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; + } + } else { + [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; + } + + return mutableQueryStringComponents; +} + +#pragma mark - + +@interface AFStreamingMultipartFormData : NSObject +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding; + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData; +@end + +#pragma mark - + +static NSArray * AFHTTPRequestSerializerObservedKeyPaths() { + static NSArray *_AFHTTPRequestSerializerObservedKeyPaths = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _AFHTTPRequestSerializerObservedKeyPaths = @[NSStringFromSelector(@selector(allowsCellularAccess)), NSStringFromSelector(@selector(cachePolicy)), NSStringFromSelector(@selector(HTTPShouldHandleCookies)), NSStringFromSelector(@selector(HTTPShouldUsePipelining)), NSStringFromSelector(@selector(networkServiceType)), NSStringFromSelector(@selector(timeoutInterval))]; + }); + + return _AFHTTPRequestSerializerObservedKeyPaths; +} + +static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerObserverContext; + +@interface AFHTTPRequestSerializer () +@property (readwrite, nonatomic, strong) NSMutableSet *mutableObservedChangedKeyPaths; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableHTTPRequestHeaders; +@property (readwrite, nonatomic, assign) AFHTTPRequestQueryStringSerializationStyle queryStringSerializationStyle; +@property (readwrite, nonatomic, copy) AFQueryStringSerializationBlock queryStringSerialization; +@end + +@implementation AFHTTPRequestSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary]; + + // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 + NSMutableArray *acceptLanguagesComponents = [NSMutableArray array]; + [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + float q = 1.0f - (idx * 0.1f); + [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]]; + *stop = q <= 0.5f; + }]; + [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"]; + + NSString *userAgent = nil; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]; +#endif +#pragma clang diagnostic pop + if (userAgent) { + if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) { + NSMutableString *mutableUserAgent = [userAgent mutableCopy]; + if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) { + userAgent = mutableUserAgent; + } + } + [self setValue:userAgent forHTTPHeaderField:@"User-Agent"]; + } + + // HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html + self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil]; + + self.mutableObservedChangedKeyPaths = [NSMutableSet set]; + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:AFHTTPRequestSerializerObserverContext]; + } + } + + return self; +} + +- (void)dealloc { + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self removeObserver:self forKeyPath:keyPath context:AFHTTPRequestSerializerObserverContext]; + } + } +} + +#pragma mark - + +- (NSDictionary *)HTTPRequestHeaders { + return [NSDictionary dictionaryWithDictionary:self.mutableHTTPRequestHeaders]; +} + +- (void)setValue:(NSString *)value +forHTTPHeaderField:(NSString *)field +{ + [self.mutableHTTPRequestHeaders setValue:value forKey:field]; +} + +- (NSString *)valueForHTTPHeaderField:(NSString *)field { + return [self.mutableHTTPRequestHeaders valueForKey:field]; +} + +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password +{ + NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", username, password]; + [self setValue:[NSString stringWithFormat:@"Basic %@", AFBase64EncodedStringFromString(basicAuthCredentials)] forHTTPHeaderField:@"Authorization"]; +} + +- (void)setAuthorizationHeaderFieldWithToken:(NSString *)token { + [self setValue:[NSString stringWithFormat:@"Token token=\"%@\"", token] forHTTPHeaderField:@"Authorization"]; +} + +- (void)clearAuthorizationHeader { + [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"]; +} + +#pragma mark - + +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style { + self.queryStringSerializationStyle = style; + self.queryStringSerialization = nil; +} + +- (void)setQueryStringSerializationWithBlock:(NSString *(^)(NSURLRequest *, NSDictionary *, NSError *__autoreleasing *))block { + self.queryStringSerialization = block; +} + +#pragma mark - + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters +{ + return [self requestWithMethod:method URLString:URLString parameters:parameters error:nil]; +} + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(URLString); + + NSURL *url = [NSURL URLWithString:URLString]; + + NSParameterAssert(url); + + NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url]; + mutableRequest.HTTPMethod = method; + + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self.mutableObservedChangedKeyPaths containsObject:keyPath]) { + [mutableRequest setValue:[self valueForKeyPath:keyPath] forKey:keyPath]; + } + } + + mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy]; + + return mutableRequest; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block +{ + return [self multipartFormRequestWithMethod:method URLString:URLString parameters:parameters constructingBodyWithBlock:block error:nil]; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); + + NSMutableURLRequest *mutableRequest = [self requestWithMethod:method URLString:URLString parameters:nil error:error]; + + __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding]; + + if (parameters) { + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + NSData *data = nil; + if ([pair.value isKindOfClass:[NSData class]]) { + data = pair.value; + } else if ([pair.value isEqual:[NSNull null]]) { + data = [NSData data]; + } else { + data = [[pair.value description] dataUsingEncoding:self.stringEncoding]; + } + + if (data) { + [formData appendPartWithFormData:data name:[pair.field description]]; + } + } + } + + if (block) { + block(formData); + } + + return [formData requestByFinalizingMultipartFormData]; +} + +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(void (^)(NSError *error))handler +{ + if (!request.HTTPBodyStream) { + return [request mutableCopy]; + } + + NSParameterAssert([fileURL isFileURL]); + + NSInputStream *inputStream = request.HTTPBodyStream; + NSOutputStream *outputStream = [[NSOutputStream alloc] initWithURL:fileURL append:NO]; + __block NSError *error = nil; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + + [inputStream open]; + [outputStream open]; + + while ([inputStream hasBytesAvailable] && [outputStream hasSpaceAvailable]) { + uint8_t buffer[1024]; + + NSInteger bytesRead = [inputStream read:buffer maxLength:1024]; + if (inputStream.streamError || bytesRead < 0) { + error = inputStream.streamError; + break; + } + + NSInteger bytesWritten = [outputStream write:buffer maxLength:(NSUInteger)bytesRead]; + if (outputStream.streamError || bytesWritten < 0) { + error = outputStream.streamError; + break; + } + + if (bytesRead == 0 && bytesWritten == 0) { + break; + } + } + + [outputStream close]; + [inputStream close]; + + if (handler) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler(error); + }); + } + }); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + mutableRequest.HTTPBodyStream = nil; + + return mutableRequest; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + NSString *query = nil; + if (self.queryStringSerialization) { + NSError *serializationError; + query = self.queryStringSerialization(request, parameters, &serializationError); + + if (serializationError) { + if (error) { + *error = serializationError; + } + + return nil; + } + } else { + switch (self.queryStringSerializationStyle) { + case AFHTTPRequestQueryStringDefaultStyle: + query = AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding); + break; + } + } + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]]; + } else { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; + } + [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]]; + } + } + + return mutableRequest; +} + +#pragma mark - NSKeyValueObserving + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(__unused id)object + change:(NSDictionary *)change + context:(void *)context +{ + if (context == AFHTTPRequestSerializerObserverContext) { + if ([change[NSKeyValueChangeNewKey] isEqual:[NSNull null]]) { + [self.mutableObservedChangedKeyPaths removeObject:keyPath]; + } else { + [self.mutableObservedChangedKeyPaths addObject:keyPath]; + } + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.mutableHTTPRequestHeaders = [[decoder decodeObjectOfClass:[NSDictionary class] forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))] mutableCopy]; + self.queryStringSerializationStyle = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))]; + [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone]; + serializer.queryStringSerializationStyle = self.queryStringSerializationStyle; + serializer.queryStringSerialization = self.queryStringSerialization; + + return serializer; +} + +@end + +#pragma mark - + +static NSString * AFCreateMultipartFormBoundary() { + return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()]; +} + +static NSString * const kAFMultipartFormCRLF = @"\r\n"; + +static inline NSString * AFMultipartFormInitialBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"--%@%@", boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormEncapsulationBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormFinalBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFContentTypeForPathExtension(NSString *extension) { +#ifdef __UTTYPE__ + NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); + NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); + if (!contentType) { + return @"application/octet-stream"; + } else { + return contentType; + } +#else +#pragma unused (extension) + return @"application/octet-stream"; +#endif +} + +NSUInteger const kAFUploadStream3GSuggestedPacketSize = 1024 * 16; +NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; + +@interface AFHTTPBodyPart : NSObject +@property (nonatomic, assign) NSStringEncoding stringEncoding; +@property (nonatomic, strong) NSDictionary *headers; +@property (nonatomic, copy) NSString *boundary; +@property (nonatomic, strong) id body; +@property (nonatomic, assign) unsigned long long bodyContentLength; +@property (nonatomic, strong) NSInputStream *inputStream; + +@property (nonatomic, assign) BOOL hasInitialBoundary; +@property (nonatomic, assign) BOOL hasFinalBoundary; + +@property (readonly, nonatomic, assign, getter = hasBytesAvailable) BOOL bytesAvailable; +@property (readonly, nonatomic, assign) unsigned long long contentLength; + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@interface AFMultipartBodyStream : NSInputStream +@property (nonatomic, assign) NSUInteger numberOfBytesInPacket; +@property (nonatomic, assign) NSTimeInterval delay; +@property (nonatomic, strong) NSInputStream *inputStream; +@property (readonly, nonatomic, assign) unsigned long long contentLength; +@property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty; + +- (id)initWithStringEncoding:(NSStringEncoding)encoding; +- (void)setInitialAndFinalBoundaries; +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; +@end + +#pragma mark - + +@interface AFStreamingMultipartFormData () +@property (readwrite, nonatomic, copy) NSMutableURLRequest *request; +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, copy) NSString *boundary; +@property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream; +@end + +@implementation AFStreamingMultipartFormData + +- (id)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding +{ + self = [super init]; + if (!self) { + return nil; + } + + self.request = urlRequest; + self.stringEncoding = encoding; + self.boundary = AFCreateMultipartFormBoundary(); + self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding]; + + return self; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + + NSString *fileName = [fileURL lastPathComponent]; + NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]); + + return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error]; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + if (![fileURL isFileURL]) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } + + NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:error]; + if (!fileAttributes) { + return NO; + } + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = fileURL; + bodyPart.bodyContentLength = [[fileAttributes objectForKey:NSFileSize] unsignedLongLongValue]; + [self.bodyStream appendHTTPBodyPart:bodyPart]; + + return YES; +} + +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = inputStream; + + bodyPart.bodyContentLength = (unsigned long long)length; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name +{ + NSParameterAssert(name); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithHeaders:(NSDictionary *)headers + body:(NSData *)body +{ + NSParameterAssert(body); + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = headers; + bodyPart.boundary = self.boundary; + bodyPart.bodyContentLength = [body length]; + bodyPart.body = body; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay +{ + self.bodyStream.numberOfBytesInPacket = numberOfBytes; + self.bodyStream.delay = delay; +} + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData { + if ([self.bodyStream isEmpty]) { + return self.request; + } + + // Reset the initial and final boundaries to ensure correct Content-Length + [self.bodyStream setInitialAndFinalBoundaries]; + [self.request setHTTPBodyStream:self.bodyStream]; + + [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"]; + [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; + + return self.request; +} + +@end + +#pragma mark - + +@interface NSStream () +@property (readwrite) NSStreamStatus streamStatus; +@property (readwrite, copy) NSError *streamError; +@end + +@interface AFMultipartBodyStream () +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts; +@property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; +@property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; +@property (readwrite, nonatomic, strong) NSOutputStream *outputStream; +@property (readwrite, nonatomic, strong) NSMutableData *buffer; +@end + +@implementation AFMultipartBodyStream +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-atomic-properties" +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100) +@synthesize delegate; +#endif +@synthesize streamStatus; +@synthesize streamError; +#pragma clang diagnostic pop + +- (id)initWithStringEncoding:(NSStringEncoding)encoding { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = encoding; + self.HTTPBodyParts = [NSMutableArray array]; + self.numberOfBytesInPacket = NSIntegerMax; + + return self; +} + +- (void)setInitialAndFinalBoundaries { + if ([self.HTTPBodyParts count] > 0) { + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + bodyPart.hasInitialBoundary = NO; + bodyPart.hasFinalBoundary = NO; + } + + [[self.HTTPBodyParts objectAtIndex:0] setHasInitialBoundary:YES]; + [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; + } +} + +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart { + [self.HTTPBodyParts addObject:bodyPart]; +} + +- (BOOL)isEmpty { + return [self.HTTPBodyParts count] == 0; +} + +#pragma mark - NSInputStream + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + if ([self streamStatus] == NSStreamStatusClosed) { + return 0; + } + + NSInteger totalNumberOfBytesRead = 0; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) { + if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { + if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { + break; + } + } else { + NSUInteger maxLength = length - (NSUInteger)totalNumberOfBytesRead; + NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength]; + if (numberOfBytesRead == -1) { + self.streamError = self.currentHTTPBodyPart.inputStream.streamError; + break; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if (self.delay > 0.0f) { + [NSThread sleepForTimeInterval:self.delay]; + } + } + } + } +#pragma clang diagnostic pop + + return totalNumberOfBytesRead; +} + +- (BOOL)getBuffer:(__unused uint8_t **)buffer + length:(__unused NSUInteger *)len +{ + return NO; +} + +- (BOOL)hasBytesAvailable { + return [self streamStatus] == NSStreamStatusOpen; +} + +#pragma mark - NSStream + +- (void)open { + if (self.streamStatus == NSStreamStatusOpen) { + return; + } + + self.streamStatus = NSStreamStatusOpen; + + [self setInitialAndFinalBoundaries]; + self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; +} + +- (void)close { + self.streamStatus = NSStreamStatusClosed; +} + +- (id)propertyForKey:(__unused NSString *)key { + return nil; +} + +- (BOOL)setProperty:(__unused id)property + forKey:(__unused NSString *)key +{ + return NO; +} + +- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + length += [bodyPart contentLength]; + } + + return length; +} + +#pragma mark - Undocumented CFReadStream Bridged Methods + +- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags + callback:(__unused CFReadStreamClientCallBack)inCallback + context:(__unused CFStreamClientContext *)inContext { + return NO; +} + +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone { + AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]]; + } + + [bodyStreamCopy setInitialAndFinalBoundaries]; + + return bodyStreamCopy; +} + +@end + +#pragma mark - + +typedef enum { + AFEncapsulationBoundaryPhase = 1, + AFHeaderPhase = 2, + AFBodyPhase = 3, + AFFinalBoundaryPhase = 4, +} AFHTTPBodyPartReadPhase; + +@interface AFHTTPBodyPart () { + AFHTTPBodyPartReadPhase _phase; + NSInputStream *_inputStream; + unsigned long long _phaseReadOffset; +} + +- (BOOL)transitionToNextPhase; +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@implementation AFHTTPBodyPart + +- (id)init { + self = [super init]; + if (!self) { + return nil; + } + + [self transitionToNextPhase]; + + return self; +} + +- (void)dealloc { + if (_inputStream) { + [_inputStream close]; + _inputStream = nil; + } +} + +- (NSInputStream *)inputStream { + if (!_inputStream) { + if ([self.body isKindOfClass:[NSData class]]) { + _inputStream = [NSInputStream inputStreamWithData:self.body]; + } else if ([self.body isKindOfClass:[NSURL class]]) { + _inputStream = [NSInputStream inputStreamWithURL:self.body]; + } else if ([self.body isKindOfClass:[NSInputStream class]]) { + _inputStream = self.body; + } else { + _inputStream = [NSInputStream inputStreamWithData:[NSData data]]; + } + } + + return _inputStream; +} + +- (NSString *)stringForHeaders { + NSMutableString *headerString = [NSMutableString string]; + for (NSString *field in [self.headers allKeys]) { + [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]]; + } + [headerString appendString:kAFMultipartFormCRLF]; + + return [NSString stringWithString:headerString]; +} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + length += [encapsulationBoundaryData length]; + + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + length += [headersData length]; + + length += _bodyContentLength; + + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + length += [closingBoundaryData length]; + + return length; +} + +- (BOOL)hasBytesAvailable { + // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer + if (_phase == AFFinalBoundaryPhase) { + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (self.inputStream.streamStatus) { + case NSStreamStatusNotOpen: + case NSStreamStatusOpening: + case NSStreamStatusOpen: + case NSStreamStatusReading: + case NSStreamStatusWriting: + return YES; + case NSStreamStatusAtEnd: + case NSStreamStatusClosed: + case NSStreamStatusError: + default: + return NO; + } +#pragma clang diagnostic pop +} + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + NSInteger totalNumberOfBytesRead = 0; + + if (_phase == AFEncapsulationBoundaryPhase) { + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFHeaderPhase) { + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:headersData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFBodyPhase) { + NSInteger numberOfBytesRead = 0; + + numberOfBytesRead = [self.inputStream read:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + if (numberOfBytesRead == -1) { + return -1; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if ([self.inputStream streamStatus] >= NSStreamStatusAtEnd) { + [self transitionToNextPhase]; + } + } + } + + if (_phase == AFFinalBoundaryPhase) { + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + totalNumberOfBytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + return totalNumberOfBytesRead; +} + +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length)); + [data getBytes:buffer range:range]; +#pragma clang diagnostic pop + + _phaseReadOffset += range.length; + + if (((NSUInteger)_phaseReadOffset) >= [data length]) { + [self transitionToNextPhase]; + } + + return (NSInteger)range.length; +} + +- (BOOL)transitionToNextPhase { + if (![[NSThread currentThread] isMainThread]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self transitionToNextPhase]; + }); + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (_phase) { + case AFEncapsulationBoundaryPhase: + _phase = AFHeaderPhase; + break; + case AFHeaderPhase: + [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; + [self.inputStream open]; + _phase = AFBodyPhase; + break; + case AFBodyPhase: + [self.inputStream close]; + _phase = AFFinalBoundaryPhase; + break; + case AFFinalBoundaryPhase: + default: + _phase = AFEncapsulationBoundaryPhase; + break; + } + _phaseReadOffset = 0; +#pragma clang diagnostic pop + + return YES; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; + + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = self.headers; + bodyPart.bodyContentLength = self.bodyContentLength; + bodyPart.body = self.body; + bodyPart.boundary = self.boundary; + + return bodyPart; +} + +@end + +#pragma mark - + +@implementation AFJSONRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithWritingOptions:(NSJSONWritingOptions)0]; +} + ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions +{ + AFJSONRequestSerializer *serializer = [[self alloc] init]; + serializer.writingOptions = writingOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.writingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writingOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFJSONRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.writingOptions = self.writingOptions; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFPropertyListRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 writeOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions +{ + AFPropertyListRequestSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.writeOptions = writeOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerializer + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-plist" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSPropertyListSerialization dataWithPropertyList:parameters format:self.format options:self.writeOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.format = self.format; + serializer.writeOptions = self.writeOptions; + + return serializer; +} + +@end diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h b/vendor/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h new file mode 100644 index 0000000..030e8fa --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1,310 @@ +// AFSerialization.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +/** + The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data. + + For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object. + */ +@protocol AFURLResponseSerialization + +/** + The response object decoded from the data associated with a specified response. + + @param response The response to be processed. + @param data The response data to be decoded. + @param error The error that occurred while attempting to decode the response data. + + @return The object decoded from the specified response data. + */ +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error; + +@end + +#pragma mark - + +/** + `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPResponseSerializer : NSObject + +- (instancetype) init; + +/** + The string encoding used to serialize parameters. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +///----------------------------------------- +/// @name Configuring Response Serialization +///----------------------------------------- + +/** + The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation. + + See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + */ +@property (nonatomic, copy) NSIndexSet *acceptableStatusCodes; + +/** + The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation. + */ +@property (nonatomic, copy) NSSet *acceptableContentTypes; + +/** + Validates the specified response and data. + + In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks. + + @param response The response to be validated. + @param data The data associated with the response. + @param error The error that occurred while attempting to validate the response. + + @return `YES` if the response is valid, otherwise `NO`. + */ +- (BOOL)validateResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error; + +@end + +#pragma mark - + + +/** + `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses. + + By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: + + - `application/json` + - `text/json` + - `text/javascript` + */ +@interface AFJSONResponseSerializer : AFHTTPResponseSerializer + +- (instancetype) init; + +/** + Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONReadingOptions readingOptions; + +/** + Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL removesKeysWithNullValues; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param readingOptions The specified JSON reading options. + */ ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions; + +@end + +#pragma mark - + +/** + `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects. + + By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +/** + `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer + +- (instancetype) init; + +/** + Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSUInteger options; + +/** + Creates and returns an XML document serializer with the specified options. + + @param mask The XML document options. + */ ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask; + +@end + +#endif + +#pragma mark - + +/** + `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFPropertyListResponseSerializer` accepts the following MIME types: + + - `application/x-plist` + */ +@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer + +- (instancetype) init; + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions." + */ +@property (nonatomic, assign) NSPropertyListReadOptions readOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param readOptions The property list reading options. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions; + +@end + +#pragma mark - + +/** + `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses. + + By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: + + - `image/tiff` + - `image/jpeg` + - `image/gif` + - `image/png` + - `image/ico` + - `image/x-icon` + - `image/bmp` + - `image/x-bmp` + - `image/x-xbitmap` + - `image/x-win-bitmap` + */ +@interface AFImageResponseSerializer : AFHTTPResponseSerializer + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +/** + The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. + */ +@property (nonatomic, assign) CGFloat imageScale; + +/** + Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default. + */ +@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; +#endif + +@end + +#pragma mark - + +/** + `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer. + */ +@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer + +/** + The component response serializers. + */ +@property (readonly, nonatomic, copy) NSArray *responseSerializers; + +/** + Creates and returns a compound serializer comprised of the specified response serializers. + + @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`. + */ ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLResponseSerializationErrorDomain` + + ### Constants + + `AFURLResponseSerializationErrorDomain` + AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +extern NSString * const AFURLResponseSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` + - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLResponseErrorKey` + The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + + `AFNetworkingOperationFailingURLResponseDataErrorKey` + The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + */ +extern NSString * const AFNetworkingOperationFailingURLResponseErrorKey; + +extern NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey; + + diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m b/vendor/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m new file mode 100644 index 0000000..083d30c --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m @@ -0,0 +1,793 @@ +// AFSerialization.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLResponseSerialization.h" + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +#import +#endif + +NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response"; +NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response"; +NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data"; + +static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) { + if (!error) { + return underlyingError; + } + + if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) { + return error; + } + + NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy]; + mutableUserInfo[NSUnderlyingErrorKey] = underlyingError; + + return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo]; +} + +static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) { + if ([error.domain isEqualToString:domain] && error.code == code) { + return YES; + } else if (error.userInfo[NSUnderlyingErrorKey]) { + return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain); + } + + return NO; +} + +static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) { + if ([JSONObject isKindOfClass:[NSArray class]]) { + NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]]; + for (id value in (NSArray *)JSONObject) { + [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)]; + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray]; + } else if ([JSONObject isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject]; + for (id key in [(NSDictionary *)JSONObject allKeys]) { + id value = [(NSDictionary *)JSONObject objectForKey:key]; + if (!value || [value isEqual:[NSNull null]]) { + [mutableDictionary removeObjectForKey:key]; + } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) { + [mutableDictionary setObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions) forKey:key]; + } + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary]; + } + + return JSONObject; +} + +@implementation AFHTTPResponseSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; + self.acceptableContentTypes = nil; + + return self; +} + +#pragma mark - + +- (BOOL)validateResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError * __autoreleasing *)error +{ + BOOL responseIsValid = YES; + NSError *validationError = nil; + + if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) { + if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]]) { + if ([data length] > 0 && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError); + } + + responseIsValid = NO; + } + + if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError); + + responseIsValid = NO; + } + } + + if (error && !responseIsValid) { + *error = validationError; + } + + return responseIsValid; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + [self validateResponse:(NSHTTPURLResponse *)response data:data error:error]; + + return data; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone]; + serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone]; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFJSONResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithReadingOptions:(NSJSONReadingOptions)0]; +} + ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions { + AFJSONResponseSerializer *serializer = [[self alloc] init]; + serializer.readingOptions = readingOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization. + // See https://github.com/rails/rails/issues/1742 + NSStringEncoding stringEncoding = self.stringEncoding; + if (response.textEncodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); + if (encoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); + } + } + + id responseObject = nil; + NSError *serializationError = nil; + @autoreleasepool { + NSString *responseString = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (responseString && ![responseString isEqualToString:@" "]) { + // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character + // See http://stackoverflow.com/a/12843465/157142 + data = [responseString dataUsingEncoding:NSUTF8StringEncoding]; + + if (data) { + if ([data length] > 0) { + responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError]; + } else { + return nil; + } + } else { + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"Data failed decoding as a UTF-8 string", @"AFNetworking", nil), + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Could not decode string: %@", @"AFNetworking", nil), responseString] + }; + + serializationError = [NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; + } + } + } + + if (self.removesKeysWithNullValues && responseObject) { + responseObject = AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions); + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue]; + self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))]; + [coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.readingOptions = self.readingOptions; + serializer.removesKeysWithNullValues = self.removesKeysWithNullValues; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFXMLParserResponseSerializer + ++ (instancetype)serializer { + AFXMLParserResponseSerializer *serializer = [[self alloc] init]; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + return [[NSXMLParser alloc] initWithData:data]; +} + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +@implementation AFXMLDocumentResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithXMLDocumentOptions:0]; +} + ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask { + AFXMLDocumentResponseSerializer *serializer = [[self alloc] init]; + serializer.options = mask; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + NSError *serializationError = nil; + NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError]; + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return document; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.options = self.options; + + return serializer; +} + +@end + +#endif + +#pragma mark - + +@implementation AFPropertyListResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions +{ + AFPropertyListResponseSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.readOptions = readOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + id responseObject; + NSError *serializationError = nil; + + if (data) { + responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError]; + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.format = self.format; + serializer.readOptions = self.readOptions; + + return serializer; +} + +@end + +#pragma mark - + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import + +static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) { + UIImage *image = [[UIImage alloc] initWithData:data]; + + return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation]; +} + +static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) { + if (!data || [data length] == 0) { + return nil; + } + + CGImageRef imageRef = NULL; + CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data); + + if ([response.MIMEType isEqualToString:@"image/png"]) { + imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) { + imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + + // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so if so, fall back to AFImageWithDataAtScale + if (imageRef) { + CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef); + CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace); + if (imageColorSpaceModel == kCGColorSpaceModelCMYK) { + CGImageRelease(imageRef); + imageRef = NULL; + } + } + } + + CGDataProviderRelease(dataProvider); + + UIImage *image = AFImageWithDataAtScale(data, scale); + if (!imageRef) { + if (image.images || !image) { + return image; + } + + imageRef = CGImageCreateCopy([image CGImage]); + if (!imageRef) { + return nil; + } + } + + size_t width = CGImageGetWidth(imageRef); + size_t height = CGImageGetHeight(imageRef); + size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef); + + if (width * height > 1024 * 1024 || bitsPerComponent > 8) { + CGImageRelease(imageRef); + + return image; + } + + size_t bytesPerRow = 0; // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace); + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + + if (colorSpaceModel == kCGColorSpaceModelRGB) { + uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wassign-enum" + if (alpha == kCGImageAlphaNone) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaNoneSkipFirst; + } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaPremultipliedFirst; + } +#pragma clang diagnostic pop + } + + CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo); + + CGColorSpaceRelease(colorSpace); + + if (!context) { + CGImageRelease(imageRef); + + return image; + } + + CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef); + CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context); + + CGContextRelease(context); + + UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation]; + + CGImageRelease(inflatedImageRef); + CGImageRelease(imageRef); + + return inflatedImage; +} +#endif + + +@implementation AFImageResponseSerializer + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil]; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + self.imageScale = [[UIScreen mainScreen] scale]; + self.automaticallyInflatesResponseImage = YES; +#endif + + return self; +} + +#pragma mark - AFURLResponseSerializer + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + if (self.automaticallyInflatesResponseImage) { + return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale); + } else { + return AFImageWithDataAtScale(data, self.imageScale); + } +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + // Ensure that the image is set to it's correct pixel width and height + NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data]; + NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; + [image addRepresentation:bitimage]; + + return image; +#endif + + return nil; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))]; +#if CGFLOAT_IS_DOUBLE + self.imageScale = [imageScale doubleValue]; +#else + self.imageScale = [imageScale floatValue]; +#endif + + self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))]; + [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + serializer.imageScale = self.imageScale; + serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage; +#endif + + return serializer; +} + +@end + +#pragma mark - + +@interface AFCompoundResponseSerializer () +@property (readwrite, nonatomic, copy) NSArray *responseSerializers; +@end + +@implementation AFCompoundResponseSerializer + ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers { + AFCompoundResponseSerializer *serializer = [[self alloc] init]; + serializer.responseSerializers = responseSerializers; + + return serializer; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + for (id serializer in self.responseSerializers) { + if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) { + continue; + } + + NSError *serializerError = nil; + id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError]; + if (responseObject) { + if (error) { + *error = AFErrorWithUnderlyingError(serializerError, *error); + } + + return responseObject; + } + } + + return [super responseObjectForResponse:response data:data error:error]; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.responseSerializers = self.responseSerializers; + + return serializer; +} + +@end diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h b/vendor/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h new file mode 100644 index 0000000..f475773 --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h @@ -0,0 +1,531 @@ +// AFURLSessionManager.h +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#import "AFNetworkReachabilityManager.h" + +/** + `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + + ## Subclassing Notes + + This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead. + + ## NSURLSession & NSURLSessionTask Delegate Methods + + `AFURLSessionManager` implements the following delegate methods: + + ### `NSURLSessionDelegate` + + - `URLSession:didBecomeInvalidWithError:` + - `URLSession:didReceiveChallenge:completionHandler:` + - `URLSessionDidFinishEventsForBackgroundURLSession:` + + ### `NSURLSessionTaskDelegate` + + - `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:` + - `URLSession:task:didReceiveChallenge:completionHandler:` + - `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:` + - `URLSession:task:didCompleteWithError:` + + ### `NSURLSessionDataDelegate` + + - `URLSession:dataTask:didReceiveResponse:completionHandler:` + - `URLSession:dataTask:didBecomeDownloadTask:` + - `URLSession:dataTask:didReceiveData:` + - `URLSession:dataTask:willCacheResponse:completionHandler:` + + ### `NSURLSessionDownloadDelegate` + + - `URLSession:downloadTask:didFinishDownloadingToURL:` + - `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:` + - `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Network Reachability Monitoring + + Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. + + ## NSCoding Caveats + + - Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`. + + ## NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original. + - Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + +@interface AFURLSessionManager : NSObject + +/** + The managed session. + */ +@property (readonly, nonatomic, strong) NSURLSession *session; + +/** + The operation queue on which delegate callbacks are run. + */ +@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) id responseSerializer; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created request operations to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///-------------------------------------- +/// @name Monitoring Network Reachability +///-------------------------------------- + +/** + The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; + +///---------------------------- +/// @name Getting Session Tasks +///---------------------------- + +/** + The data, upload, and download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *tasks; + +/** + The data tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *dataTasks; + +/** + The upload tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *uploadTasks; + +/** + The download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *downloadTasks; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +@property (nonatomic, strong) dispatch_queue_t completionQueue; + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +@property (nonatomic, strong) dispatch_group_t completionGroup; + +///--------------------------------- +/// @name Working Around System Bugs +///--------------------------------- + +/** + Whether to attempt to retry creation of upload tasks for background sessions when initial call returns `nil`. `NO` by default. + + @bug As of iOS 7.0, there is a bug where upload tasks created for background tasks are sometimes `nil`. As a workaround, if this property is `YES`, AFNetworking will follow Apple's recommendation to try creating the task again. + + @see https://github.com/AFNetworking/AFNetworking/issues/1675 + */ +@property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a manager for a session created with the specified configuration. This is the designated initializer. + + @param configuration The configuration used to create the managed session. + + @return A manager for a newly-created session. + */ +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration; + +/** + Invalidates the managed session, optionally canceling pending tasks. + + @param cancelPendingTasks Whether or not to cancel pending tasks. + */ +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks; + +///------------------------- +/// @name Running Data Tasks +///------------------------- + +/** + Creates an `NSURLSessionDataTask` with the specified request. + + @param request The HTTP request for the request. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; + +///--------------------------- +/// @name Running Upload Tasks +///--------------------------- + +/** + Creates an `NSURLSessionUploadTask` with the specified request for a local file. + + @param request The HTTP request for the request. + @param fileURL A URL to the local file to be uploaded. + @param progress A progress object monitoring the current upload progress. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + + @see `attemptsToRecreateUploadTasksForBackgroundSessions` + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body. + + @param request The HTTP request for the request. + @param bodyData A data object containing the HTTP body to be uploaded. + @param progress A progress object monitoring the current upload progress. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(NSData *)bodyData + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified streaming request. + + @param request The HTTP request for the request. + @param progress A progress object monitoring the current upload progress. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; + +///----------------------------- +/// @name Running Download Tasks +///----------------------------- + +/** + Creates an `NSURLSessionDownloadTask` with the specified request. + + @param request The HTTP request for the request. + @param progress A progress object monitoring the current download progress. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + + @warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler; + +/** + Creates an `NSURLSessionDownloadTask` with the specified resume data. + + @param resumeData The data used to resume downloading. + @param progress A progress object monitoring the current download progress. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler; + +///--------------------------------- +/// @name Getting Progress for Tasks +///--------------------------------- + +/** + Returns the upload progress of the specified task. + + @param uploadTask The session upload task. Must not be `nil`. + + @return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable. + */ +- (NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask; + +/** + Returns the download progress of the specified task. + + @param downloadTask The session download task. Must not be `nil`. + + @return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable. + */ +- (NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask; + +///----------------------------------------- +/// @name Setting Session Delegate Callbacks +///----------------------------------------- + +/** + Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`. + + @param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation. + */ +- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block; + +/** + Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block; + +///-------------------------------------- +/// @name Setting Task Delegate Callbacks +///-------------------------------------- + +/** + Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`. + + @param block A block object to be executed when a task requires a new request body stream. + */ +- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block; + +/** + Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`. + + @param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response. + */ +- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block; + +/** + Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a session task has received a request specific authentication challenge. The block returns the disposition of the authentication challenge, and takes four arguments: the session, the task, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block; + +/** + Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`. + + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block; + +/** + Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`. + + @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task. + */ +- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block; + +///------------------------------------------- +/// @name Setting Data Task Delegate Callbacks +///------------------------------------------- + +/** + Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`. + + @param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response. + */ +- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block; + +/** + Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`. + + @param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become. + */ +- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block; + +/** + Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block; + +/** + Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`. + + @param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response. + */ +- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block; + +/** + Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`. + + @param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session. + */ +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block; + +///----------------------------------------------- +/// @name Setting Download Task Delegate Callbacks +///----------------------------------------------- + +/** + Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`. + + @param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `AFURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error. + */ +- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block; + +/** + Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block; + +/** + Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`. + + @param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded. + */ +- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block; + +@end + +#endif + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when a task begins executing. + + @deprecated Use `AFNetworkingTaskDidResumeNotification` instead. + */ +extern NSString * const AFNetworkingTaskDidStartNotification DEPRECATED_ATTRIBUTE; + +/** + Posted when a task resumes. + */ +extern NSString * const AFNetworkingTaskDidResumeNotification; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + + @deprecated Use `AFNetworkingTaskDidCompleteNotification` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishNotification DEPRECATED_ATTRIBUTE; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + */ +extern NSString * const AFNetworkingTaskDidCompleteNotification; + +/** + Posted when a task suspends its execution. + */ +extern NSString * const AFNetworkingTaskDidSuspendNotification; + +/** + Posted when a session is invalidated. + */ +extern NSString * const AFURLSessionDidInvalidateNotification; + +/** + Posted when a session download task encountered an error when moving the temporary download file to a specified destination. + */ +extern NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if response data exists for the task. + + @deprecated Use `AFNetworkingTaskDidCompleteResponseDataKey` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishResponseDataKey DEPRECATED_ATTRIBUTE; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if response data exists for the task. + */ +extern NSString * const AFNetworkingTaskDidCompleteResponseDataKey; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the response was serialized. + + @deprecated Use `AFNetworkingTaskDidCompleteSerializedResponseKey` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishSerializedResponseKey DEPRECATED_ATTRIBUTE; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the response was serialized. + */ +extern NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the task has an associated response serializer. + + @deprecated Use `AFNetworkingTaskDidCompleteResponseSerializerKey` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishResponseSerializerKey DEPRECATED_ATTRIBUTE; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the task has an associated response serializer. + */ +extern NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an the response data has been stored directly to disk. + + @deprecated Use `AFNetworkingTaskDidCompleteAssetPathKey` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishAssetPathKey DEPRECATED_ATTRIBUTE; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an the response data has been stored directly to disk. + */ +extern NSString * const AFNetworkingTaskDidCompleteAssetPathKey; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an error exists. + + @deprecated Use `AFNetworkingTaskDidCompleteErrorKey` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishErrorKey DEPRECATED_ATTRIBUTE; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an error exists. + */ +extern NSString * const AFNetworkingTaskDidCompleteErrorKey; diff --git a/vendor/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m b/vendor/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m new file mode 100644 index 0000000..d53e6ec --- /dev/null +++ b/vendor/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m @@ -0,0 +1,1079 @@ +// AFURLSessionManager.m +// +// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLSessionManager.h" +#import + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + +static dispatch_queue_t url_session_manager_creation_queue() { + static dispatch_queue_t af_url_session_manager_creation_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_creation_queue = dispatch_queue_create("com.alamofire.networking.session.manager.creation", DISPATCH_QUEUE_SERIAL); + }); + + return af_url_session_manager_creation_queue; +} + +static dispatch_queue_t url_session_manager_processing_queue() { + static dispatch_queue_t af_url_session_manager_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_processing_queue = dispatch_queue_create("com.alamofire.networking.session.manager.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_url_session_manager_processing_queue; +} + +static dispatch_group_t url_session_manager_completion_group() { + static dispatch_group_t af_url_session_manager_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_completion_group = dispatch_group_create(); + }); + + return af_url_session_manager_completion_group; +} + +NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume"; +NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete"; +NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend"; +NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate"; +NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error"; + +NSString * const AFNetworkingTaskDidStartNotification = @"com.alamofire.networking.task.resume"; // Deprecated +NSString * const AFNetworkingTaskDidFinishNotification = @"com.alamofire.networking.task.complete"; // Deprecated + +NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; +NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; +NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; +NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error"; +NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; + +NSString * const AFNetworkingTaskDidFinishSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; // Deprecated +NSString * const AFNetworkingTaskDidFinishResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; // Deprecated +NSString * const AFNetworkingTaskDidFinishResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; // Deprecated +NSString * const AFNetworkingTaskDidFinishErrorKey = @"com.alamofire.networking.task.complete.error"; // Deprecated +NSString * const AFNetworkingTaskDidFinishAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; // Deprecated + +static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock"; + +static NSUInteger const AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask = 3; + +static void * AFTaskStateChangedContext = &AFTaskStateChangedContext; + +typedef void (^AFURLSessionDidBecomeInvalidBlock)(NSURLSession *session, NSError *error); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); + +typedef NSURLRequest * (^AFURLSessionTaskWillPerformHTTPRedirectionBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionTaskDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); +typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSession *session); + +typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task); +typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend); +typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error); + +typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response); +typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask); +typedef void (^AFURLSessionDataTaskDidReceiveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data); +typedef NSCachedURLResponse * (^AFURLSessionDataTaskWillCacheResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse); + +typedef NSURL * (^AFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location); +typedef void (^AFURLSessionDownloadTaskDidWriteDataBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite); +typedef void (^AFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes); + +typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error); + +#pragma mark - + +@interface AFURLSessionManagerTaskDelegate : NSObject +@property (nonatomic, weak) AFURLSessionManager *manager; +@property (nonatomic, strong) NSMutableData *mutableData; +@property (nonatomic, strong) NSProgress *progress; +@property (nonatomic, copy) NSURL *downloadFileURL; +@property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler; +@end + +@implementation AFURLSessionManagerTaskDelegate + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.mutableData = [NSMutableData data]; + + self.progress = [NSProgress progressWithTotalUnitCount:0]; + + return self; +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + task:(__unused NSURLSessionTask *)task + didSendBodyData:(__unused int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + self.progress.totalUnitCount = totalBytesExpectedToSend; + self.progress.completedUnitCount = totalBytesSent; +} + +- (void)URLSession:(__unused NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + __strong AFURLSessionManager *manager = self.manager; + + __block id responseObject = nil; + + __block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer; + + if (self.downloadFileURL) { + userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL; + } else if (self.mutableData) { + userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = [NSData dataWithData:self.mutableData]; + } + + if (error) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = error; + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, error); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + } else { + dispatch_async(url_session_manager_processing_queue(), ^{ + NSError *serializationError = nil; + responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:[NSData dataWithData:self.mutableData] error:&serializationError]; + + if (self.downloadFileURL) { + responseObject = self.downloadFileURL; + } + + if (responseObject) { + userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject; + } + + if (serializationError) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError; + } + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, serializationError); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + }); + } +#pragma clang diagnostic pop +} + +#pragma mark - NSURLSessionDataTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + dataTask:(__unused NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + [self.mutableData appendData:data]; +} + +#pragma mark - NSURLSessionDownloadTaskDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + NSError *fileManagerError = nil; + self.downloadFileURL = nil; + + if (self.downloadTaskDidFinishDownloading) { + self.downloadFileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (self.downloadFileURL) { + [[NSFileManager defaultManager] moveItemAtURL:location toURL:self.downloadFileURL error:&fileManagerError]; + + if (fileManagerError) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:fileManagerError.userInfo]; + } + } + } +} + +- (void)URLSession:(__unused NSURLSession *)session + downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask + didWriteData:(__unused int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + self.progress.totalUnitCount = totalBytesExpectedToWrite; + self.progress.completedUnitCount = totalBytesWritten; +} + +- (void)URLSession:(__unused NSURLSession *)session + downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes { + self.progress.totalUnitCount = expectedTotalBytes; + self.progress.completedUnitCount = fileOffset; +} + +@end + +#pragma mark - + +/* + A workaround for issues related to key-value observing the `state` of an `NSURLSessionTask`. + + See https://github.com/AFNetworking/AFNetworking/issues/1477 + */ + +static inline void af_swizzleSelector(Class class, SEL originalSelector, SEL swizzledSelector) { + Method originalMethod = class_getInstanceMethod(class, originalSelector); + Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); + if (class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))) { + class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); + } else { + method_exchangeImplementations(originalMethod, swizzledMethod); + } +} + +static NSString * const AFNSURLSessionTaskDidResumeNotification = @"com.alamofire.networking.nsurlsessiontask.resume"; +static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofire.networking.nsurlsessiontask.suspend"; + +@interface NSURLSessionTask (_AFStateObserving) +@end + +@implementation NSURLSessionTask (_AFStateObserving) + ++ (void)load { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_swizzleSelector([self class], @selector(resume), @selector(af_resume)); + af_swizzleSelector([self class], @selector(suspend), @selector(af_suspend)); + }); +} + +#pragma mark - + +- (void)af_resume { + NSURLSessionTaskState state = self.state; + [self af_resume]; + + if (state != NSURLSessionTaskStateRunning) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidResumeNotification object:self]; + } +} + +- (void)af_suspend { + NSURLSessionTaskState state = self.state; + [self af_suspend]; + + if (state != NSURLSessionTaskStateSuspended) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidSuspendNotification object:self]; + } +} + +@end + +#pragma mark - + +@interface AFURLSessionManager () +@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration; +@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue; +@property (readwrite, nonatomic, strong) NSURLSession *session; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableTaskDelegatesKeyedByTaskIdentifier; +@property (readwrite, nonatomic, strong) NSLock *lock; +@property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid; +@property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession; +@property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidReceiveAuthenticationChallengeBlock taskDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskWillCacheResponseBlock dataTaskWillCacheResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidWriteDataBlock downloadTaskDidWriteData; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume; +@end + +@implementation AFURLSessionManager + +- (instancetype)init { + return [self initWithSessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + self = [super init]; + if (!self) { + return nil; + } + + if (!configuration) { + configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + } + + self.sessionConfiguration = configuration; + + self.operationQueue = [[NSOperationQueue alloc] init]; + self.operationQueue.maxConcurrentOperationCount = 1; + + self.session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue]; + + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; + + self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init]; + + self.lock = [[NSLock alloc] init]; + self.lock.name = AFURLSessionManagerLockName; + + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + for (NSURLSessionDataTask *task in dataTasks) { + [self addDelegateForDataTask:task completionHandler:nil]; + } + + for (NSURLSessionUploadTask *uploadTask in uploadTasks) { + [self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil]; + } + + for (NSURLSessionDownloadTask *downloadTask in downloadTasks) { + [self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil]; + } + }]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidResume:) name:AFNSURLSessionTaskDidResumeNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidSuspend:) name:AFNSURLSessionTaskDidSuspendNotification object:nil]; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (void)taskDidResume:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task isKindOfClass:[NSURLSessionTask class]]) { + AFURLSessionManager *manager = [self delegateForTask:task].manager; + if ([manager isEqual:self]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidResumeNotification object:task]; + }); + } + } +} + +- (void)taskDidSuspend:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task isKindOfClass:[NSURLSessionTask class]]) { + AFURLSessionManager *manager = [self delegateForTask:task].manager; + if ([manager isEqual:self]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidSuspendNotification object:task]; + }); + } + } +} + +#pragma mark - + +- (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + AFURLSessionManagerTaskDelegate *delegate = nil; + [self.lock lock]; + delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)]; + [self.lock unlock]; + + return delegate; +} + +- (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate + forTask:(NSURLSessionTask *)task +{ + NSParameterAssert(task); + NSParameterAssert(delegate); + + [self.lock lock]; + self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate; + [self.lock unlock]; +} + +- (void)addDelegateForDataTask:(NSURLSessionDataTask *)dataTask + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + [self setDelegate:delegate forTask:dataTask]; +} + +- (void)addDelegateForUploadTask:(NSURLSessionUploadTask *)uploadTask + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + int64_t totalUnitCount = uploadTask.countOfBytesExpectedToSend; + if(totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [uploadTask.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if(contentLength) { + totalUnitCount = (int64_t) [contentLength longLongValue]; + } + } + + delegate.progress = [NSProgress progressWithTotalUnitCount:totalUnitCount]; + delegate.progress.pausingHandler = ^{ + [uploadTask suspend]; + }; + delegate.progress.cancellationHandler = ^{ + [uploadTask cancel]; + }; + + if (progress) { + *progress = delegate.progress; + } + + [self setDelegate:delegate forTask:uploadTask]; +} + +- (void)addDelegateForDownloadTask:(NSURLSessionDownloadTask *)downloadTask + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + if (destination) { + delegate.downloadTaskDidFinishDownloading = ^NSURL * (NSURLSession * __unused session, NSURLSessionDownloadTask *task, NSURL *location) { + return destination(location, task.response); + }; + } + + if (progress) { + *progress = delegate.progress; + } + + [self setDelegate:delegate forTask:downloadTask]; +} + +- (void)removeDelegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + [self.lock lock]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)]; + [self.lock unlock]; +} + +- (void)removeAllDelegates { + [self.lock lock]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeAllObjects]; + [self.lock unlock]; +} + +#pragma mark - + +- (NSArray *)tasksForKeyPath:(NSString *)keyPath { + __block NSArray *tasks = nil; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(dataTasks))]) { + tasks = dataTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(uploadTasks))]) { + tasks = uploadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(downloadTasks))]) { + tasks = downloadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(tasks))]) { + tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"]; + } + + dispatch_semaphore_signal(semaphore); + }]; + + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + + return tasks; +} + +- (NSArray *)tasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)dataTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)uploadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)downloadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +#pragma mark - + +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks { + dispatch_async(dispatch_get_main_queue(), ^{ + if (cancelPendingTasks) { + [self.session invalidateAndCancel]; + } else { + [self.session finishTasksAndInvalidate]; + } + }); +} + +#pragma mark - + +- (void)setResponseSerializer:(id )responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - + +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionDataTask *dataTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + dataTask = [self.session dataTaskWithRequest:request]; + }); + + [self addDelegateForDataTask:dataTask completionHandler:completionHandler]; + + return dataTask; +} + +#pragma mark - + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + }); + + if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) { + for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask; attempts++) { + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + } + } + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(NSData *)bodyData + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithRequest:request fromData:bodyData]; + }); + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithStreamedRequest:request]; + }); + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +#pragma mark - + +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + downloadTask = [self.session downloadTaskWithRequest:request]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:progress destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + downloadTask = [self.session downloadTaskWithResumeData:resumeData]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:progress destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +#pragma mark - + +- (NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask { + return [[self delegateForTask:uploadTask] progress]; +} + +- (NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask { + return [[self delegateForTask:downloadTask] progress]; +} + +#pragma mark - + +- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block { + self.sessionDidBecomeInvalid = block; +} + +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.sessionDidReceiveAuthenticationChallenge = block; +} + +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block { + self.didFinishEventsForBackgroundURLSession = block; +} + +#pragma mark - + +- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block { + self.taskNeedNewBodyStream = block; +} + +- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block { + self.taskWillPerformHTTPRedirection = block; +} + +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.taskDidReceiveAuthenticationChallenge = block; +} + +- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block { + self.taskDidSendBodyData = block; +} + +- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block { + self.taskDidComplete = block; +} + +#pragma mark - + +- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block { + self.dataTaskDidReceiveResponse = block; +} + +- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block { + self.dataTaskDidBecomeDownloadTask = block; +} + +- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block { + self.dataTaskDidReceiveData = block; +} + +- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block { + self.dataTaskWillCacheResponse = block; +} + +#pragma mark - + +- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block { + self.downloadTaskDidFinishDownloading = block; +} + +- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block { + self.downloadTaskDidWriteData = block; +} + +- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block { + self.downloadTaskDidResume = block; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, self.session, self.operationQueue]; +} + +- (BOOL)respondsToSelector:(SEL)selector { + if (selector == @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)) { + return self.taskWillPerformHTTPRedirection != nil; + } else if (selector == @selector(URLSession:dataTask:didReceiveResponse:completionHandler:)) { + return self.dataTaskDidReceiveResponse != nil; + } else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) { + return self.dataTaskWillCacheResponse != nil; + } else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) { + return self.didFinishEventsForBackgroundURLSession != nil; + } + + return [[self class] instancesRespondToSelector:selector]; +} + +#pragma mark - NSURLSessionDelegate + +- (void)URLSession:(NSURLSession *)session +didBecomeInvalidWithError:(NSError *)error +{ + if (self.sessionDidBecomeInvalid) { + self.sessionDidBecomeInvalid(session, error); + } + + [self removeAllDelegates]; + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDidInvalidateNotification object:session]; +} + +- (void)URLSession:(NSURLSession *)session +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.sessionDidReceiveAuthenticationChallenge) { + disposition = self.sessionDidReceiveAuthenticationChallenge(session, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + if (credential) { + disposition = NSURLSessionAuthChallengeUseCredential; + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } else { + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +willPerformHTTPRedirection:(NSHTTPURLResponse *)response + newRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLRequest *))completionHandler +{ + NSURLRequest *redirectRequest = request; + + if (self.taskWillPerformHTTPRedirection) { + redirectRequest = self.taskWillPerformHTTPRedirection(session, task, response, request); + } + + if (completionHandler) { + completionHandler(redirectRequest); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.taskDidReceiveAuthenticationChallenge) { + disposition = self.taskDidReceiveAuthenticationChallenge(session, task, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + disposition = NSURLSessionAuthChallengeUseCredential; + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + } else { + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler +{ + NSInputStream *inputStream = nil; + + if (self.taskNeedNewBodyStream) { + inputStream = self.taskNeedNewBodyStream(session, task); + } else if (task.originalRequest.HTTPBodyStream && [task.originalRequest.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { + inputStream = [task.originalRequest.HTTPBodyStream copy]; + } + + if (completionHandler) { + completionHandler(inputStream); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + didSendBodyData:(int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + + int64_t totalUnitCount = totalBytesExpectedToSend; + if(totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if(contentLength) { + totalUnitCount = (int64_t) [contentLength longLongValue]; + } + } + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + [delegate URLSession:session task:task didSendBodyData:bytesSent totalBytesSent:totalBytesSent totalBytesExpectedToSend:totalUnitCount]; + + if (self.taskDidSendBodyData) { + self.taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalUnitCount); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + + // delegate may be nil when completing a task in the background + if (delegate) { + [delegate URLSession:session task:task didCompleteWithError:error]; + + [self removeDelegateForTask:task]; + } + + if (self.taskDidComplete) { + self.taskDidComplete(session, task, error); + } + +} + +#pragma mark - NSURLSessionDataDelegate + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didReceiveResponse:(NSURLResponse *)response + completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler +{ + NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow; + + if (self.dataTaskDidReceiveResponse) { + disposition = self.dataTaskDidReceiveResponse(session, dataTask, response); + } + + if (completionHandler) { + completionHandler(disposition); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + if (delegate) { + [self removeDelegateForTask:dataTask]; + [self setDelegate:delegate forTask:downloadTask]; + } + + if (self.dataTaskDidBecomeDownloadTask) { + self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + [delegate URLSession:session dataTask:dataTask didReceiveData:data]; + + if (self.dataTaskDidReceiveData) { + self.dataTaskDidReceiveData(session, dataTask, data); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + willCacheResponse:(NSCachedURLResponse *)proposedResponse + completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler +{ + NSCachedURLResponse *cachedResponse = proposedResponse; + + if (self.dataTaskWillCacheResponse) { + cachedResponse = self.dataTaskWillCacheResponse(session, dataTask, proposedResponse); + } + + if (completionHandler) { + completionHandler(cachedResponse); + } +} + +- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session { + if (self.didFinishEventsForBackgroundURLSession) { + dispatch_async(dispatch_get_main_queue(), ^{ + self.didFinishEventsForBackgroundURLSession(session); + }); + } +} + +#pragma mark - NSURLSessionDownloadDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + if (self.downloadTaskDidFinishDownloading) { + NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (fileURL) { + delegate.downloadFileURL = fileURL; + NSError *error = nil; + [[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error]; + if (error) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:error.userInfo]; + } + + return; + } + } + + if (delegate) { + [delegate URLSession:session downloadTask:downloadTask didFinishDownloadingToURL:location]; + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didWriteData:(int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + [delegate URLSession:session downloadTask:downloadTask didWriteData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite]; + + if (self.downloadTaskDidWriteData) { + self.downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + [delegate URLSession:session downloadTask:downloadTask didResumeAtOffset:fileOffset expectedTotalBytes:expectedTotalBytes]; + + if (self.downloadTaskDidResume) { + self.downloadTaskDidResume(session, downloadTask, fileOffset, expectedTotalBytes); + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + + self = [self initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration]; +} + +@end + +#endif diff --git a/vendor/Pods/AFNetworking/LICENSE b/vendor/Pods/AFNetworking/LICENSE new file mode 100644 index 0000000..0616192 --- /dev/null +++ b/vendor/Pods/AFNetworking/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/Pods/AFNetworking/README.md b/vendor/Pods/AFNetworking/README.md new file mode 100644 index 0000000..13e080c --- /dev/null +++ b/vendor/Pods/AFNetworking/README.md @@ -0,0 +1,383 @@ +

+ AFNetworking +

+ +[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.svg)](https://travis-ci.org/AFNetworking/AFNetworking) + +AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of the [Foundation URL Loading System](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. + +Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. + +Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did! + +## How To Get Started + +- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps +- Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles on the Wiki](https://github.com/AFNetworking/AFNetworking/wiki) +- Check out the [documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at all of the APIs available in AFNetworking +- Read the [AFNetworking 2.0 Migration Guide](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-2.0-Migration-Guide) for an overview of the architectural changes from 1.0. + +## Communication + +- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). (Tag 'afnetworking') +- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). +- If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue. +- If you **have a feature request**, open an issue. +- If you **want to contribute**, submit a pull request. + +### Installation with CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects. See the ["Getting Started" guide for more information](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking). + +#### Podfile + +```ruby +platform :ios, '7.0' +pod "AFNetworking", "~> 2.0" +``` + +## Requirements + +| AFNetworking Version | Minimum iOS Target | Minimum OS X Target | Notes | +|:--------------------:|:---------------------------:|:----------------------------:|:-------------------------------------------------------------------------:| +| 2.x | iOS 6 | OS X 10.8 | Xcode 5 is required. `AFHTTPSessionManager` requires iOS 7 or OS X 10.9. | +| [1.x](https://github.com/AFNetworking/AFNetworking/tree/1.x) | iOS 5 | Mac OS X 10.7 | | +| [0.10.x](https://github.com/AFNetworking/AFNetworking/tree/0.10.x) | iOS 4 | Mac OS X 10.6 | | + +(OS X projects must support [64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)). + +## Architecture + +### NSURLConnection + +- `AFURLConnectionOperation` +- `AFHTTPRequestOperation` +- `AFHTTPRequestOperationManager` + +### NSURLSession _(iOS 7 / Mac OS X 10.9)_ + +- `AFURLSessionManager` +- `AFHTTPSessionManager` + +### Serialization + +* `` + - `AFHTTPRequestSerializer` + - `AFJSONRequestSerializer` + - `AFPropertyListRequestSerializer` +* `` + - `AFHTTPResponseSerializer` + - `AFJSONResponseSerializer` + - `AFXMLParserResponseSerializer` + - `AFXMLDocumentResponseSerializer` _(Mac OS X)_ + - `AFPropertyListResponseSerializer` + - `AFImageResponseSerializer` + - `AFCompoundResponseSerializer` + +### Additional Functionality + +- `AFSecurityPolicy` +- `AFNetworkReachabilityManager` + +## Usage + +### HTTP Request Operation Manager + +`AFHTTPRequestOperationManager` encapsulates the common patterns of communicating with a web application over HTTP, including request creation, response serialization, network reachability monitoring, and security, as well as request operation management. + +#### `GET` Request + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +[manager GET:@"http://example.com/resources.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"JSON: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +``` + +#### `POST` URL-Form-Encoded Request + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +NSDictionary *parameters = @{@"foo": @"bar"}; +[manager POST:@"http://example.com/resources.json" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"JSON: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +``` + +#### `POST` Multi-Part Request + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +NSDictionary *parameters = @{@"foo": @"bar"}; +NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; +[manager POST:@"http://example.com/resources.json" parameters:parameters constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:filePath name:@"image" error:nil]; +} success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"Success: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +``` + +--- + +### AFURLSessionManager + +`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + +#### Creating a Download Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { + NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; + return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; +} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) { + NSLog(@"File downloaded to: %@", filePath); +}]; +[downloadTask resume]; +``` + +#### Creating an Upload Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; +NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"Success: %@ %@", response, responseObject); + } +}]; +[uploadTask resume]; +``` + +#### Creating an Upload Task for a Multi-Part Request, with Progress + +```objective-c +NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil]; + } error:nil]; + +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; +NSProgress *progress = nil; + +NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } +}]; + +[uploadTask resume]; +``` + +#### Creating a Data Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } +}]; +[dataTask resume]; +``` + +--- + +### Request Serialization + +Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body. + +```objective-c +NSString *URLString = @"http://example.com"; +NSDictionary *parameters = @{@"foo": @"bar", @"baz": @[@1, @2, @3]}; +``` + +#### Query String Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:URLString parameters:parameters error:nil]; +``` + + GET http://example.com?foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### URL Form Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters]; +``` + + POST http://example.com/ + Content-Type: application/x-www-form-urlencoded + + foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### JSON Parameter Encoding + +```objective-c +[[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters]; +``` + + POST http://example.com/ + Content-Type: application/json + + {"foo": "bar", "baz": [1,2,3]} + +--- + +### Network Reachability Manager + +`AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + +#### Shared Network Reachability + +```objective-c +[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status)); +}]; +``` + +#### HTTP Manager Reachability + +```objective-c +NSURL *baseURL = [NSURL URLWithString:@"http://example.com/"]; +AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL]; + +NSOperationQueue *operationQueue = manager.operationQueue; +[manager.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + switch (status) { + case AFNetworkReachabilityStatusReachableViaWWAN: + case AFNetworkReachabilityStatusReachableViaWiFi: + [operationQueue setSuspended:NO]; + break; + case AFNetworkReachabilityStatusNotReachable: + default: + [operationQueue setSuspended:YES]; + break; + } +}]; + +[manager.reachabilityManager startMonitoring]; +``` + +--- + +### Security Policy + +`AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + +Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. + +#### Allowing Invalid SSL Certificates + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +manager.securityPolicy.allowInvalidCertificates = YES; // not recommended for production +``` + +--- + +### AFHTTPRequestOperation + +`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. + +Although `AFHTTPRequestOperationManager` is usually the best way to go about making requests, `AFHTTPRequestOperation` can be used by itself. + +#### `GET` with `AFHTTPRequestOperation` + +```objective-c +NSURL *URL = [NSURL URLWithString:@"http://example.com/resources/123.json"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; +AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request]; +op.responseSerializer = [AFJSONResponseSerializer serializer]; +[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"JSON: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +[[NSOperationQueue mainQueue] addOperation:op]; +``` + +#### Batch of Operations + +```objective-c +NSMutableArray *mutableOperations = [NSMutableArray array]; +for (NSURL *fileURL in filesToUpload) { + NSURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:fileURL name:@"images[]" error:nil]; + }]; + + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + + [mutableOperations addObject:operation]; +} + +NSArray *operations = [AFURLConnectionOperation batchOfRequestOperations:@[...] progressBlock:^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) { + NSLog(@"%lu of %lu complete", numberOfFinishedOperations, totalNumberOfOperations); +} completionBlock:^(NSArray *operations) { + NSLog(@"All operations in batch complete"); +}]; +[[NSOperationQueue mainQueue] addOperations:operations waitUntilFinished:NO]; +``` + +## Unit Tests + +AFNetworking includes a suite of unit tests within the Tests subdirectory. In order to run the unit tests, you must install the testing dependencies via [CocoaPods](http://cocoapods.org/): + + $ cd Tests + $ pod install + +Once testing dependencies are installed, you can execute the test suite via the 'iOS Tests' and 'OS X Tests' schemes within Xcode. + +### Running Tests from the Command Line + +Tests can also be run from the command line or within a continuous integration environment. The [`xcpretty`](https://github.com/mneorr/xcpretty) utility needs to be installed before running the tests from the command line: + + $ gem install xcpretty + +Once `xcpretty` is installed, you can execute the suite via `rake test`. + +## Credits + +AFNetworking was originally created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla). + +AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/). + +And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors). + +## Contact + +Follow AFNetworking on Twitter ([@AFNetworking](https://twitter.com/AFNetworking)) + +### Maintainers + +- [Mattt Thompson](http://github.com/mattt) ([@mattt](https://twitter.com/mattt)) + +## License + +AFNetworking is available under the MIT license. See the LICENSE file for more info. diff --git a/vendor/Pods/BuildHeaders/MASShortcut/MASShortcut+Monitoring.h b/vendor/Pods/BuildHeaders/MASShortcut/MASShortcut+Monitoring.h deleted file mode 120000 index ab639d6..0000000 --- a/vendor/Pods/BuildHeaders/MASShortcut/MASShortcut+Monitoring.h +++ /dev/null @@ -1 +0,0 @@ -../../MASShortcut/MASShortcut+Monitoring.h \ No newline at end of file diff --git a/vendor/Pods/BuildHeaders/MASShortcut/MASShortcut+UserDefaults.h b/vendor/Pods/BuildHeaders/MASShortcut/MASShortcut+UserDefaults.h deleted file mode 120000 index 8c895dc..0000000 --- a/vendor/Pods/BuildHeaders/MASShortcut/MASShortcut+UserDefaults.h +++ /dev/null @@ -1 +0,0 @@ -../../MASShortcut/MASShortcut+UserDefaults.h \ No newline at end of file diff --git a/vendor/Pods/BuildHeaders/MASShortcut/MASShortcut.h b/vendor/Pods/BuildHeaders/MASShortcut/MASShortcut.h deleted file mode 120000 index 3e9dbbe..0000000 --- a/vendor/Pods/BuildHeaders/MASShortcut/MASShortcut.h +++ /dev/null @@ -1 +0,0 @@ -../../MASShortcut/MASShortcut.h \ No newline at end of file diff --git a/vendor/Pods/BuildHeaders/MASShortcut/MASShortcutView+UserDefaults.h b/vendor/Pods/BuildHeaders/MASShortcut/MASShortcutView+UserDefaults.h deleted file mode 120000 index 2451dc3..0000000 --- a/vendor/Pods/BuildHeaders/MASShortcut/MASShortcutView+UserDefaults.h +++ /dev/null @@ -1 +0,0 @@ -../../MASShortcut/MASShortcutView+UserDefaults.h \ No newline at end of file diff --git a/vendor/Pods/BuildHeaders/MASShortcut/MASShortcutView.h b/vendor/Pods/BuildHeaders/MASShortcut/MASShortcutView.h deleted file mode 120000 index 6d0341c..0000000 --- a/vendor/Pods/BuildHeaders/MASShortcut/MASShortcutView.h +++ /dev/null @@ -1 +0,0 @@ -../../MASShortcut/MASShortcutView.h \ No newline at end of file diff --git a/vendor/Pods/BuildHeaders/SocketRocket/NSData+SRB64Additions.h b/vendor/Pods/BuildHeaders/SocketRocket/NSData+SRB64Additions.h deleted file mode 120000 index fad7e4f..0000000 --- a/vendor/Pods/BuildHeaders/SocketRocket/NSData+SRB64Additions.h +++ /dev/null @@ -1 +0,0 @@ -../../SocketRocket/SocketRocket/NSData+SRB64Additions.h \ No newline at end of file diff --git a/vendor/Pods/BuildHeaders/SocketRocket/SRWebSocket.h b/vendor/Pods/BuildHeaders/SocketRocket/SRWebSocket.h deleted file mode 120000 index 177652d..0000000 --- a/vendor/Pods/BuildHeaders/SocketRocket/SRWebSocket.h +++ /dev/null @@ -1 +0,0 @@ -../../SocketRocket/SocketRocket/SRWebSocket.h \ No newline at end of file diff --git a/vendor/Pods/BuildHeaders/SocketRocket/base64.h b/vendor/Pods/BuildHeaders/SocketRocket/base64.h deleted file mode 120000 index 8b858cf..0000000 --- a/vendor/Pods/BuildHeaders/SocketRocket/base64.h +++ /dev/null @@ -1 +0,0 @@ -../../SocketRocket/SocketRocket/base64.h \ No newline at end of file diff --git a/vendor/Pods/Headers/MASShortcut/MASShortcut+Monitoring.h b/vendor/Pods/Headers/MASShortcut/MASShortcut+Monitoring.h deleted file mode 120000 index ab639d6..0000000 --- a/vendor/Pods/Headers/MASShortcut/MASShortcut+Monitoring.h +++ /dev/null @@ -1 +0,0 @@ -../../MASShortcut/MASShortcut+Monitoring.h \ No newline at end of file diff --git a/vendor/Pods/Headers/MASShortcut/MASShortcut+UserDefaults.h b/vendor/Pods/Headers/MASShortcut/MASShortcut+UserDefaults.h deleted file mode 120000 index 8c895dc..0000000 --- a/vendor/Pods/Headers/MASShortcut/MASShortcut+UserDefaults.h +++ /dev/null @@ -1 +0,0 @@ -../../MASShortcut/MASShortcut+UserDefaults.h \ No newline at end of file diff --git a/vendor/Pods/Headers/MASShortcut/MASShortcut.h b/vendor/Pods/Headers/MASShortcut/MASShortcut.h deleted file mode 120000 index 3e9dbbe..0000000 --- a/vendor/Pods/Headers/MASShortcut/MASShortcut.h +++ /dev/null @@ -1 +0,0 @@ -../../MASShortcut/MASShortcut.h \ No newline at end of file diff --git a/vendor/Pods/Headers/MASShortcut/MASShortcutView+UserDefaults.h b/vendor/Pods/Headers/MASShortcut/MASShortcutView+UserDefaults.h deleted file mode 120000 index 2451dc3..0000000 --- a/vendor/Pods/Headers/MASShortcut/MASShortcutView+UserDefaults.h +++ /dev/null @@ -1 +0,0 @@ -../../MASShortcut/MASShortcutView+UserDefaults.h \ No newline at end of file diff --git a/vendor/Pods/Headers/MASShortcut/MASShortcutView.h b/vendor/Pods/Headers/MASShortcut/MASShortcutView.h deleted file mode 120000 index 6d0341c..0000000 --- a/vendor/Pods/Headers/MASShortcut/MASShortcutView.h +++ /dev/null @@ -1 +0,0 @@ -../../MASShortcut/MASShortcutView.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h b/vendor/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h new file mode 120000 index 0000000..ac762c8 --- /dev/null +++ b/vendor/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h b/vendor/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h new file mode 120000 index 0000000..9dcc623 --- /dev/null +++ b/vendor/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h b/vendor/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h new file mode 120000 index 0000000..56feb9f --- /dev/null +++ b/vendor/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h b/vendor/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h new file mode 120000 index 0000000..68fc774 --- /dev/null +++ b/vendor/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/AFNetworking/AFNetworking.h b/vendor/Pods/Headers/Public/AFNetworking/AFNetworking.h new file mode 120000 index 0000000..a5a38da --- /dev/null +++ b/vendor/Pods/Headers/Public/AFNetworking/AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworking.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h b/vendor/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h new file mode 120000 index 0000000..fd1322d --- /dev/null +++ b/vendor/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFSecurityPolicy.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h b/vendor/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h new file mode 120000 index 0000000..d9b35fb --- /dev/null +++ b/vendor/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h b/vendor/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h new file mode 120000 index 0000000..ca8209b --- /dev/null +++ b/vendor/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h b/vendor/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h new file mode 120000 index 0000000..e36a765 --- /dev/null +++ b/vendor/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h b/vendor/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h new file mode 120000 index 0000000..835101d --- /dev/null +++ b/vendor/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLSessionManager.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/MASShortcut/MASDictionaryTransformer.h b/vendor/Pods/Headers/Public/MASShortcut/MASDictionaryTransformer.h new file mode 120000 index 0000000..164f2c7 --- /dev/null +++ b/vendor/Pods/Headers/Public/MASShortcut/MASDictionaryTransformer.h @@ -0,0 +1 @@ +../../../MASShortcut/Framework/MASDictionaryTransformer.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/MASShortcut/MASHotKey.h b/vendor/Pods/Headers/Public/MASShortcut/MASHotKey.h new file mode 120000 index 0000000..2318610 --- /dev/null +++ b/vendor/Pods/Headers/Public/MASShortcut/MASHotKey.h @@ -0,0 +1 @@ +../../../MASShortcut/Framework/MASHotKey.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/MASShortcut/MASKeyCodes.h b/vendor/Pods/Headers/Public/MASShortcut/MASKeyCodes.h new file mode 120000 index 0000000..f79ee7f --- /dev/null +++ b/vendor/Pods/Headers/Public/MASShortcut/MASKeyCodes.h @@ -0,0 +1 @@ +../../../MASShortcut/Framework/MASKeyCodes.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/MASShortcut/MASShortcut.h b/vendor/Pods/Headers/Public/MASShortcut/MASShortcut.h new file mode 120000 index 0000000..1d4ee64 --- /dev/null +++ b/vendor/Pods/Headers/Public/MASShortcut/MASShortcut.h @@ -0,0 +1 @@ +../../../MASShortcut/Framework/MASShortcut.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/MASShortcut/MASShortcutBinder.h b/vendor/Pods/Headers/Public/MASShortcut/MASShortcutBinder.h new file mode 120000 index 0000000..385133c --- /dev/null +++ b/vendor/Pods/Headers/Public/MASShortcut/MASShortcutBinder.h @@ -0,0 +1 @@ +../../../MASShortcut/Framework/MASShortcutBinder.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/MASShortcut/MASShortcutMonitor.h b/vendor/Pods/Headers/Public/MASShortcut/MASShortcutMonitor.h new file mode 120000 index 0000000..9e112f9 --- /dev/null +++ b/vendor/Pods/Headers/Public/MASShortcut/MASShortcutMonitor.h @@ -0,0 +1 @@ +../../../MASShortcut/Framework/MASShortcutMonitor.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/MASShortcut/MASShortcutValidator.h b/vendor/Pods/Headers/Public/MASShortcut/MASShortcutValidator.h new file mode 120000 index 0000000..fa2b046 --- /dev/null +++ b/vendor/Pods/Headers/Public/MASShortcut/MASShortcutValidator.h @@ -0,0 +1 @@ +../../../MASShortcut/Framework/MASShortcutValidator.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/MASShortcut/MASShortcutView+Bindings.h b/vendor/Pods/Headers/Public/MASShortcut/MASShortcutView+Bindings.h new file mode 120000 index 0000000..221ed8e --- /dev/null +++ b/vendor/Pods/Headers/Public/MASShortcut/MASShortcutView+Bindings.h @@ -0,0 +1 @@ +../../../MASShortcut/Framework/MASShortcutView+Bindings.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/MASShortcut/MASShortcutView.h b/vendor/Pods/Headers/Public/MASShortcut/MASShortcutView.h new file mode 120000 index 0000000..6b1d366 --- /dev/null +++ b/vendor/Pods/Headers/Public/MASShortcut/MASShortcutView.h @@ -0,0 +1 @@ +../../../MASShortcut/Framework/MASShortcutView.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/MASShortcut/Shortcut.h b/vendor/Pods/Headers/Public/MASShortcut/Shortcut.h new file mode 120000 index 0000000..534e351 --- /dev/null +++ b/vendor/Pods/Headers/Public/MASShortcut/Shortcut.h @@ -0,0 +1 @@ +../../../MASShortcut/Framework/Shortcut.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/SocketRocket/NSData+SRB64Additions.h b/vendor/Pods/Headers/Public/SocketRocket/NSData+SRB64Additions.h new file mode 120000 index 0000000..e33307a --- /dev/null +++ b/vendor/Pods/Headers/Public/SocketRocket/NSData+SRB64Additions.h @@ -0,0 +1 @@ +../../../SocketRocket/SocketRocket/NSData+SRB64Additions.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/SocketRocket/SRWebSocket.h b/vendor/Pods/Headers/Public/SocketRocket/SRWebSocket.h new file mode 120000 index 0000000..b41c867 --- /dev/null +++ b/vendor/Pods/Headers/Public/SocketRocket/SRWebSocket.h @@ -0,0 +1 @@ +../../../SocketRocket/SocketRocket/SRWebSocket.h \ No newline at end of file diff --git a/vendor/Pods/Headers/Public/SocketRocket/base64.h b/vendor/Pods/Headers/Public/SocketRocket/base64.h new file mode 120000 index 0000000..df09eae --- /dev/null +++ b/vendor/Pods/Headers/Public/SocketRocket/base64.h @@ -0,0 +1 @@ +../../../SocketRocket/SocketRocket/base64.h \ No newline at end of file diff --git a/vendor/Pods/Headers/____Pods-MASShortcut-prefix.h b/vendor/Pods/Headers/Public/____Pods-AFNetworking-prefix.h similarity index 100% rename from vendor/Pods/Headers/____Pods-MASShortcut-prefix.h rename to vendor/Pods/Headers/Public/____Pods-AFNetworking-prefix.h diff --git a/vendor/Pods/Headers/____Pods-SocketRocket-prefix.h b/vendor/Pods/Headers/Public/____Pods-MASShortcut-prefix.h similarity index 100% rename from vendor/Pods/Headers/____Pods-SocketRocket-prefix.h rename to vendor/Pods/Headers/Public/____Pods-MASShortcut-prefix.h diff --git a/vendor/Pods/Pods-MASShortcut-prefix.pch b/vendor/Pods/Headers/Public/____Pods-SocketRocket-prefix.h similarity index 100% rename from vendor/Pods/Pods-MASShortcut-prefix.pch rename to vendor/Pods/Headers/Public/____Pods-SocketRocket-prefix.h diff --git a/vendor/Pods/Headers/Public/____Pods-environment.h b/vendor/Pods/Headers/Public/____Pods-environment.h new file mode 100644 index 0000000..432df3a --- /dev/null +++ b/vendor/Pods/Headers/Public/____Pods-environment.h @@ -0,0 +1,8 @@ + +// To check if a library is compiled with CocoaPods you +// can use the `COCOAPODS` macro definition which is +// defined in the xcconfigs so it is available in +// headers also when they are imported in the client +// project. + + diff --git a/vendor/Pods/Headers/SocketRocket/NSData+SRB64Additions.h b/vendor/Pods/Headers/SocketRocket/NSData+SRB64Additions.h deleted file mode 120000 index fad7e4f..0000000 --- a/vendor/Pods/Headers/SocketRocket/NSData+SRB64Additions.h +++ /dev/null @@ -1 +0,0 @@ -../../SocketRocket/SocketRocket/NSData+SRB64Additions.h \ No newline at end of file diff --git a/vendor/Pods/Headers/SocketRocket/SRWebSocket.h b/vendor/Pods/Headers/SocketRocket/SRWebSocket.h deleted file mode 120000 index 177652d..0000000 --- a/vendor/Pods/Headers/SocketRocket/SRWebSocket.h +++ /dev/null @@ -1 +0,0 @@ -../../SocketRocket/SocketRocket/SRWebSocket.h \ No newline at end of file diff --git a/vendor/Pods/Headers/SocketRocket/base64.h b/vendor/Pods/Headers/SocketRocket/base64.h deleted file mode 120000 index 8b858cf..0000000 --- a/vendor/Pods/Headers/SocketRocket/base64.h +++ /dev/null @@ -1 +0,0 @@ -../../SocketRocket/SocketRocket/base64.h \ No newline at end of file diff --git a/vendor/Pods/Headers/____Pods-environment.h b/vendor/Pods/Headers/____Pods-environment.h deleted file mode 100644 index c84414f..0000000 --- a/vendor/Pods/Headers/____Pods-environment.h +++ /dev/null @@ -1,20 +0,0 @@ - -// To check if a library is compiled with CocoaPods you -// can use the `COCOAPODS` macro definition which is -// defined in the xcconfigs so it is available in -// headers also when they are imported in the client -// project. - - -// MASShortcut -#define COCOAPODS_POD_AVAILABLE_MASShortcut -#define COCOAPODS_VERSION_MAJOR_MASShortcut 1 -#define COCOAPODS_VERSION_MINOR_MASShortcut 2 -#define COCOAPODS_VERSION_PATCH_MASShortcut 3 - -// SocketRocket -#define COCOAPODS_POD_AVAILABLE_SocketRocket -#define COCOAPODS_VERSION_MAJOR_SocketRocket 0 -#define COCOAPODS_VERSION_MINOR_SocketRocket 3 -#define COCOAPODS_VERSION_PATCH_SocketRocket 1 - diff --git a/vendor/Pods/MASShortcut/Framework/MASDictionaryTransformer.h b/vendor/Pods/MASShortcut/Framework/MASDictionaryTransformer.h new file mode 100644 index 0000000..6e53fd8 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASDictionaryTransformer.h @@ -0,0 +1,19 @@ +extern NSString *const MASDictionaryTransformerName; + +/** + Converts shortcuts for storage in user defaults. + + User defaults can’t stored custom types directly, they have to + be serialized to `NSData` or some other supported type like an + `NSDictionary`. In Cocoa Bindings, the conversion can be done + using value transformers like this one. + + There’s a built-in transformer (`NSKeyedUnarchiveFromDataTransformerName`) + that converts any `NSCoding` types to `NSData`, but with shortcuts + it makes sense to use a dictionary instead – the defaults look better + when inspected with the `defaults` command-line utility and the + format is compatible with an older sortcut library called Shortcut + Recorder. +*/ +@interface MASDictionaryTransformer : NSValueTransformer +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASDictionaryTransformer.m b/vendor/Pods/MASShortcut/Framework/MASDictionaryTransformer.m new file mode 100644 index 0000000..9e4c82b --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASDictionaryTransformer.m @@ -0,0 +1,51 @@ +#import "MASDictionaryTransformer.h" +#import "MASShortcut.h" + +NSString *const MASDictionaryTransformerName = @"MASDictionaryTransformer"; + +static NSString *const MASKeyCodeKey = @"keyCode"; +static NSString *const MASModifierFlagsKey = @"modifierFlags"; + +@implementation MASDictionaryTransformer + ++ (BOOL) allowsReverseTransformation +{ + return YES; +} + +// Storing nil values as an empty dictionary lets us differ between +// “not available, use default value” and “explicitly set to none”. +// See http://stackoverflow.com/questions/5540760 for details. +- (NSDictionary*) reverseTransformedValue: (MASShortcut*) shortcut +{ + if (shortcut == nil) { + return [NSDictionary dictionary]; + } else { + return @{ + MASKeyCodeKey: @([shortcut keyCode]), + MASModifierFlagsKey: @([shortcut modifierFlags]) + }; + } +} + +- (MASShortcut*) transformedValue: (NSDictionary*) dictionary +{ + // We have to be defensive here as the value may come from user defaults. + if (![dictionary isKindOfClass:[NSDictionary class]]) { + return nil; + } + + id keyCodeBox = [dictionary objectForKey:MASKeyCodeKey]; + id modifierFlagsBox = [dictionary objectForKey:MASModifierFlagsKey]; + + SEL integerValue = @selector(integerValue); + if (![keyCodeBox respondsToSelector:integerValue] || ![modifierFlagsBox respondsToSelector:integerValue]) { + return nil; + } + + return [MASShortcut + shortcutWithKeyCode:[keyCodeBox integerValue] + modifierFlags:[modifierFlagsBox integerValue]]; +} + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASHotKey.h b/vendor/Pods/MASShortcut/Framework/MASHotKey.h new file mode 100644 index 0000000..1d267e4 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASHotKey.h @@ -0,0 +1,12 @@ +#import "MASShortcut.h" + +extern FourCharCode const MASHotKeySignature; + +@interface MASHotKey : NSObject + +@property(readonly) UInt32 carbonID; +@property(copy) dispatch_block_t action; + ++ (instancetype) registeredHotKeyWithShortcut: (MASShortcut*) shortcut; + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASHotKey.m b/vendor/Pods/MASShortcut/Framework/MASHotKey.m new file mode 100644 index 0000000..c5ab744 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASHotKey.m @@ -0,0 +1,44 @@ +#import "MASHotKey.h" + +FourCharCode const MASHotKeySignature = 'MASS'; + +@interface MASHotKey () +@property(assign) EventHotKeyRef hotKeyRef; +@property(assign) UInt32 carbonID; +@end + +@implementation MASHotKey + +- (instancetype) initWithShortcut: (MASShortcut*) shortcut +{ + self = [super init]; + + static UInt32 CarbonHotKeyID = 0; + + _carbonID = ++CarbonHotKeyID; + EventHotKeyID hotKeyID = { .signature = MASHotKeySignature, .id = _carbonID }; + + OSStatus status = RegisterEventHotKey([shortcut carbonKeyCode], [shortcut carbonFlags], + hotKeyID, GetEventDispatcherTarget(), 0, &_hotKeyRef); + + if (status != noErr) { + return nil; + } + + return self; +} + ++ (instancetype) registeredHotKeyWithShortcut: (MASShortcut*) shortcut +{ + return [[self alloc] initWithShortcut:shortcut]; +} + +- (void) dealloc +{ + if (_hotKeyRef) { + UnregisterEventHotKey(_hotKeyRef); + _hotKeyRef = NULL; + } +} + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASKeyCodes.h b/vendor/Pods/MASShortcut/Framework/MASKeyCodes.h new file mode 100644 index 0000000..8c1ce06 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASKeyCodes.h @@ -0,0 +1,42 @@ +#import + +// These glyphs are missed in Carbon.h +enum { + kMASShortcutGlyphEject = 0x23CF, + kMASShortcutGlyphClear = 0x2715, + kMASShortcutGlyphDeleteLeft = 0x232B, + kMASShortcutGlyphDeleteRight = 0x2326, + kMASShortcutGlyphLeftArrow = 0x2190, + kMASShortcutGlyphRightArrow = 0x2192, + kMASShortcutGlyphUpArrow = 0x2191, + kMASShortcutGlyphDownArrow = 0x2193, + kMASShortcutGlyphEscape = 0x238B, + kMASShortcutGlyphHelp = 0x003F, + kMASShortcutGlyphPageDown = 0x21DF, + kMASShortcutGlyphPageUp = 0x21DE, + kMASShortcutGlyphTabRight = 0x21E5, + kMASShortcutGlyphReturn = 0x2305, + kMASShortcutGlyphReturnR2L = 0x21A9, + kMASShortcutGlyphPadClear = 0x2327, + kMASShortcutGlyphNorthwestArrow = 0x2196, + kMASShortcutGlyphSoutheastArrow = 0x2198, +} MASShortcutGlyph; + +NS_INLINE NSString* NSStringFromMASKeyCode(unsigned short ch) +{ + return [NSString stringWithFormat:@"%C", ch]; +} + +NS_INLINE NSUInteger MASPickCocoaModifiers(NSUInteger flags) +{ + return (flags & (NSControlKeyMask | NSShiftKeyMask | NSAlternateKeyMask | NSCommandKeyMask)); +} + +NS_INLINE UInt32 MASCarbonModifiersFromCocoaModifiers(NSUInteger cocoaFlags) +{ + return + (cocoaFlags & NSCommandKeyMask ? cmdKey : 0) + | (cocoaFlags & NSAlternateKeyMask ? optionKey : 0) + | (cocoaFlags & NSControlKeyMask ? controlKey : 0) + | (cocoaFlags & NSShiftKeyMask ? shiftKey : 0); +} diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcut.h b/vendor/Pods/MASShortcut/Framework/MASShortcut.h new file mode 100644 index 0000000..e175317 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcut.h @@ -0,0 +1,70 @@ +#import "MASKeyCodes.h" + +/** + A model class to hold a key combination. + + This class just represents a combination of keys. It does not care if + the combination is valid or can be used as a hotkey, it doesn’t watch + the input system for the shortcut appearance, nor it does access user + defaults. +*/ +@interface MASShortcut : NSObject + +/** + The virtual key code for the keyboard key. + + Hardware independent, same as in `NSEvent`. See `Events.h` in the HIToolbox + framework for a complete list, or Command-click this symbol: `kVK_ANSI_A`. +*/ +@property (nonatomic, readonly) NSUInteger keyCode; + +/** + Cocoa keyboard modifier flags. + + Same as in `NSEvent`: `NSCommandKeyMask`, `NSAlternateKeyMask`, etc. +*/ +@property (nonatomic, readonly) NSUInteger modifierFlags; + +/** + Same as `keyCode`, just a different type. +*/ +@property (nonatomic, readonly) UInt32 carbonKeyCode; + +/** + Carbon modifier flags. + + A bit sum of `cmdKey`, `optionKey`, etc. +*/ +@property (nonatomic, readonly) UInt32 carbonFlags; + +/** + A string representing the “key” part of a shortcut, like the `5` in `⌘5`. +*/ +@property (nonatomic, readonly) NSString *keyCodeString; + +/** + A key-code string used in key equivalent matching. + + For precise meaning of “key equivalents” see the `keyEquivalent` + property of `NSMenuItem`. Here the string is used to support shortcut + validation (“is the shortcut already taken in this menu?”) and + for display in `NSMenu`. +*/ +@property (nonatomic, readonly) NSString *keyCodeStringForKeyEquivalent; + +/** + A string representing the shortcut modifiers, like the `⌘` in `⌘5`. +*/ +@property (nonatomic, readonly) NSString *modifierFlagsString; + +- (instancetype)initWithKeyCode:(NSUInteger)code modifierFlags:(NSUInteger)flags; ++ (instancetype)shortcutWithKeyCode:(NSUInteger)code modifierFlags:(NSUInteger)flags; + +/** + Creates a new shortcut from an `NSEvent` object. + + This is just a convenience initializer that reads the key code and modifiers from an `NSEvent`. +*/ ++ (instancetype)shortcutWithEvent:(NSEvent *)anEvent; + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcut.m b/vendor/Pods/MASShortcut/Framework/MASShortcut.m new file mode 100644 index 0000000..e6fa63d --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcut.m @@ -0,0 +1,241 @@ +#import "MASShortcut.h" + +static NSString *const MASShortcutKeyCode = @"KeyCode"; +static NSString *const MASShortcutModifierFlags = @"ModifierFlags"; + +@implementation MASShortcut + +#pragma mark Initialization + +- (instancetype)initWithKeyCode:(NSUInteger)code modifierFlags:(NSUInteger)flags +{ + self = [super init]; + if (self) { + _keyCode = code; + _modifierFlags = MASPickCocoaModifiers(flags); + } + return self; +} + ++ (instancetype)shortcutWithKeyCode:(NSUInteger)code modifierFlags:(NSUInteger)flags +{ + return [[self alloc] initWithKeyCode:code modifierFlags:flags]; +} + ++ (instancetype)shortcutWithEvent:(NSEvent *)event +{ + return [[self alloc] initWithKeyCode:event.keyCode modifierFlags:event.modifierFlags]; +} + +#pragma mark Shortcut Accessors + +- (UInt32)carbonKeyCode +{ + return (self.keyCode == NSNotFound ? 0 : (UInt32)self.keyCode); +} + +- (UInt32)carbonFlags +{ + return MASCarbonModifiersFromCocoaModifiers(self.modifierFlags); +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"%@%@", self.modifierFlagsString, self.keyCodeString]; +} + +- (NSString *)keyCodeStringForKeyEquivalent +{ + NSString *keyCodeString = self.keyCodeString; + if (keyCodeString.length > 1) { + switch (self.keyCode) { + case kVK_F1: return NSStringFromMASKeyCode(0xF704); + case kVK_F2: return NSStringFromMASKeyCode(0xF705); + case kVK_F3: return NSStringFromMASKeyCode(0xF706); + case kVK_F4: return NSStringFromMASKeyCode(0xF707); + case kVK_F5: return NSStringFromMASKeyCode(0xF708); + case kVK_F6: return NSStringFromMASKeyCode(0xF709); + case kVK_F7: return NSStringFromMASKeyCode(0xF70a); + case kVK_F8: return NSStringFromMASKeyCode(0xF70b); + case kVK_F9: return NSStringFromMASKeyCode(0xF70c); + case kVK_F10: return NSStringFromMASKeyCode(0xF70d); + case kVK_F11: return NSStringFromMASKeyCode(0xF70e); + case kVK_F12: return NSStringFromMASKeyCode(0xF70f); + // From this point down I am guessing F13 etc come sequentially, I don't have a keyboard to test. + case kVK_F13: return NSStringFromMASKeyCode(0xF710); + case kVK_F14: return NSStringFromMASKeyCode(0xF711); + case kVK_F15: return NSStringFromMASKeyCode(0xF712); + case kVK_F16: return NSStringFromMASKeyCode(0xF713); + case kVK_F17: return NSStringFromMASKeyCode(0xF714); + case kVK_F18: return NSStringFromMASKeyCode(0xF715); + case kVK_F19: return NSStringFromMASKeyCode(0xF716); + case kVK_Space: return NSStringFromMASKeyCode(0x20); + default: return @""; + } + } + return keyCodeString.lowercaseString; +} + +- (NSString *)keyCodeString +{ + // Some key codes don't have an equivalent + switch (self.keyCode) { + case NSNotFound: return @""; + case kVK_F1: return @"F1"; + case kVK_F2: return @"F2"; + case kVK_F3: return @"F3"; + case kVK_F4: return @"F4"; + case kVK_F5: return @"F5"; + case kVK_F6: return @"F6"; + case kVK_F7: return @"F7"; + case kVK_F8: return @"F8"; + case kVK_F9: return @"F9"; + case kVK_F10: return @"F10"; + case kVK_F11: return @"F11"; + case kVK_F12: return @"F12"; + case kVK_F13: return @"F13"; + case kVK_F14: return @"F14"; + case kVK_F15: return @"F15"; + case kVK_F16: return @"F16"; + case kVK_F17: return @"F17"; + case kVK_F18: return @"F18"; + case kVK_F19: return @"F19"; + case kVK_Space: return NSLocalizedString(@"Space", @"Shortcut glyph name for SPACE key"); + case kVK_Escape: return NSStringFromMASKeyCode(kMASShortcutGlyphEscape); + case kVK_Delete: return NSStringFromMASKeyCode(kMASShortcutGlyphDeleteLeft); + case kVK_ForwardDelete: return NSStringFromMASKeyCode(kMASShortcutGlyphDeleteRight); + case kVK_LeftArrow: return NSStringFromMASKeyCode(kMASShortcutGlyphLeftArrow); + case kVK_RightArrow: return NSStringFromMASKeyCode(kMASShortcutGlyphRightArrow); + case kVK_UpArrow: return NSStringFromMASKeyCode(kMASShortcutGlyphUpArrow); + case kVK_DownArrow: return NSStringFromMASKeyCode(kMASShortcutGlyphDownArrow); + case kVK_Help: return NSStringFromMASKeyCode(kMASShortcutGlyphHelp); + case kVK_PageUp: return NSStringFromMASKeyCode(kMASShortcutGlyphPageUp); + case kVK_PageDown: return NSStringFromMASKeyCode(kMASShortcutGlyphPageDown); + case kVK_Tab: return NSStringFromMASKeyCode(kMASShortcutGlyphTabRight); + case kVK_Return: return NSStringFromMASKeyCode(kMASShortcutGlyphReturnR2L); + + // Keypad + case kVK_ANSI_Keypad0: return @"0"; + case kVK_ANSI_Keypad1: return @"1"; + case kVK_ANSI_Keypad2: return @"2"; + case kVK_ANSI_Keypad3: return @"3"; + case kVK_ANSI_Keypad4: return @"4"; + case kVK_ANSI_Keypad5: return @"5"; + case kVK_ANSI_Keypad6: return @"6"; + case kVK_ANSI_Keypad7: return @"7"; + case kVK_ANSI_Keypad8: return @"8"; + case kVK_ANSI_Keypad9: return @"9"; + case kVK_ANSI_KeypadDecimal: return @"."; + case kVK_ANSI_KeypadMultiply: return @"*"; + case kVK_ANSI_KeypadPlus: return @"+"; + case kVK_ANSI_KeypadClear: return NSStringFromMASKeyCode(kMASShortcutGlyphPadClear); + case kVK_ANSI_KeypadDivide: return @"/"; + case kVK_ANSI_KeypadEnter: return NSStringFromMASKeyCode(kMASShortcutGlyphReturn); + case kVK_ANSI_KeypadMinus: return @"–"; + case kVK_ANSI_KeypadEquals: return @"="; + + // Hardcode + case 119: return NSStringFromMASKeyCode(kMASShortcutGlyphSoutheastArrow); + case 115: return NSStringFromMASKeyCode(kMASShortcutGlyphNorthwestArrow); + } + + // Everything else should be printable so look it up in the current keyboard + OSStatus error = noErr; + NSString *keystroke = nil; + TISInputSourceRef inputSource = TISCopyCurrentKeyboardLayoutInputSource(); + if (inputSource) { + CFDataRef layoutDataRef = TISGetInputSourceProperty(inputSource, kTISPropertyUnicodeKeyLayoutData); + if (layoutDataRef) { + UCKeyboardLayout *layoutData = (UCKeyboardLayout *)CFDataGetBytePtr(layoutDataRef); + UniCharCount length = 0; + UniChar chars[256] = { 0 }; + UInt32 deadKeyState = 0; + error = UCKeyTranslate(layoutData, (UInt16)self.keyCode, kUCKeyActionDisplay, 0, // No modifiers + LMGetKbdType(), kUCKeyTranslateNoDeadKeysMask, &deadKeyState, + sizeof(chars) / sizeof(UniChar), &length, chars); + keystroke = ((error == noErr) && length ? [NSString stringWithCharacters:chars length:length] : @""); + } + CFRelease(inputSource); + } + + // Validate keystroke + if (keystroke.length) { + static NSMutableCharacterSet *validChars = nil; + if (validChars == nil) { + validChars = [[NSMutableCharacterSet alloc] init]; + [validChars formUnionWithCharacterSet:[NSCharacterSet alphanumericCharacterSet]]; + [validChars formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]]; + [validChars formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]]; + } + for (NSUInteger i = 0, length = keystroke.length; i < length; i++) { + if (![validChars characterIsMember:[keystroke characterAtIndex:i]]) { + keystroke = @""; + break; + } + } + } + + // Finally, we've got a shortcut! + return keystroke.uppercaseString; +} + +- (NSString *)modifierFlagsString +{ + unichar chars[4]; + NSUInteger count = 0; + // These are in the same order as the menu manager shows them + if (self.modifierFlags & NSControlKeyMask) chars[count++] = kControlUnicode; + if (self.modifierFlags & NSAlternateKeyMask) chars[count++] = kOptionUnicode; + if (self.modifierFlags & NSShiftKeyMask) chars[count++] = kShiftUnicode; + if (self.modifierFlags & NSCommandKeyMask) chars[count++] = kCommandUnicode; + return (count ? [NSString stringWithCharacters:chars length:count] : @""); +} + +#pragma mark NSObject + +- (BOOL) isEqual: (MASShortcut*) object +{ + return [object isKindOfClass:[self class]] + && (object.keyCode == self.keyCode) + && (object.modifierFlags == self.modifierFlags); +} + +- (NSUInteger) hash +{ + return self.keyCode + self.modifierFlags; +} + +#pragma mark NSCoding + +- (void)encodeWithCoder:(NSCoder *)coder +{ + [coder encodeInteger:(self.keyCode != NSNotFound ? (NSInteger)self.keyCode : - 1) forKey:MASShortcutKeyCode]; + [coder encodeInteger:(NSInteger)self.modifierFlags forKey:MASShortcutModifierFlags]; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder +{ + self = [super init]; + if (self) { + NSInteger code = [decoder decodeIntegerForKey:MASShortcutKeyCode]; + _keyCode = (code < 0 ? NSNotFound : (NSUInteger)code); + _modifierFlags = [decoder decodeIntegerForKey:MASShortcutModifierFlags]; + } + return self; +} + +#pragma mark NSSecureCoding + ++ (BOOL)supportsSecureCoding +{ + return YES; +} + +#pragma mark NSCopying + +- (instancetype) copyWithZone:(NSZone *)zone +{ + return [[self class] shortcutWithKeyCode:_keyCode modifierFlags:_modifierFlags]; +} + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcutBinder.h b/vendor/Pods/MASShortcut/Framework/MASShortcutBinder.h new file mode 100644 index 0000000..e7406de --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcutBinder.h @@ -0,0 +1,67 @@ +#import "MASShortcutMonitor.h" + +/** + Binds actions to user defaults keys. + + If you store shortcuts in user defaults (for example by binding + a `MASShortcutView` to user defaults), you can use this class to + connect an action directly to a user defaults key. If the shortcut + stored under the key changes, the action will get automatically + updated to the new one. + + This class is mostly a wrapper around a `MASShortcutMonitor`. It + watches the changes in user defaults and updates the shortcut monitor + accordingly with the new shortcuts. +*/ +@interface MASShortcutBinder : NSObject + +/** + A convenience shared instance. + + You may use it so that you don’t have to manage an instance by hand, + but it’s perfectly fine to allocate and use a separate instance instead. +*/ ++ (instancetype) sharedBinder; + +/** + The underlying shortcut monitor. +*/ +@property(strong) MASShortcutMonitor *shortcutMonitor; + +/** + Binding options customizing the access to user defaults. + + As an example, you can use `NSValueTransformerNameBindingOption` to customize + the storage format used for the shortcuts. By default the shortcuts are converted + from `NSData` (`NSKeyedUnarchiveFromDataTransformerName`). Note that if the + binder is to work with `MASShortcutView`, both object have to use the same storage + format. +*/ +@property(copy) NSDictionary *bindingOptions; + +/** + Binds given action to a shortcut stored under the given defaults key. + + In other words, no matter what shortcut you store under the given key, + pressing it will always trigger the given action. +*/ +- (void) bindShortcutWithDefaultsKey: (NSString*) defaultsKeyName toAction: (dispatch_block_t) action; + +/** + Disconnect the binding between user defaults and action. + + In other words, the shortcut stored under the given key will no longer trigger an action. +*/ +- (void) breakBindingWithDefaultsKey: (NSString*) defaultsKeyName; + +/** + Register default shortcuts in user defaults. + + This is a convenience frontent to `[NSUserDefaults registerDefaults]`. + The dictionary should contain a map of user defaults’ keys to appropriate + keyboard shortcuts. The shortcuts will be transformed according to + `bindingOptions` and registered using `registerDefaults`. +*/ +- (void) registerDefaultShortcuts: (NSDictionary*) defaultShortcuts; + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcutBinder.m b/vendor/Pods/MASShortcut/Framework/MASShortcutBinder.m new file mode 100644 index 0000000..bf85c41 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcutBinder.m @@ -0,0 +1,114 @@ +#import "MASShortcutBinder.h" +#import "MASShortcut.h" + +@interface MASShortcutBinder () +@property(strong) NSMutableDictionary *actions; +@property(strong) NSMutableDictionary *shortcuts; +@end + +@implementation MASShortcutBinder + +#pragma mark Initialization + +- (id) init +{ + self = [super init]; + [self setActions:[NSMutableDictionary dictionary]]; + [self setShortcuts:[NSMutableDictionary dictionary]]; + [self setShortcutMonitor:[MASShortcutMonitor sharedMonitor]]; + [self setBindingOptions:@{NSValueTransformerNameBindingOption: NSKeyedUnarchiveFromDataTransformerName}]; + return self; +} + +- (void) dealloc +{ + for (NSString *bindingName in [_actions allKeys]) { + [self unbind:bindingName]; + } +} + ++ (instancetype) sharedBinder +{ + static dispatch_once_t once; + static MASShortcutBinder *sharedInstance; + dispatch_once(&once, ^{ + sharedInstance = [[self alloc] init]; + }); + return sharedInstance; +} + +#pragma mark Registration + +- (void) bindShortcutWithDefaultsKey: (NSString*) defaultsKeyName toAction: (dispatch_block_t) action +{ + [_actions setObject:[action copy] forKey:defaultsKeyName]; + [self bind:defaultsKeyName toObject:[NSUserDefaultsController sharedUserDefaultsController] + withKeyPath:[@"values." stringByAppendingString:defaultsKeyName] options:_bindingOptions]; +} + +- (void) breakBindingWithDefaultsKey: (NSString*) defaultsKeyName +{ + [_shortcutMonitor unregisterShortcut:[_shortcuts objectForKey:defaultsKeyName]]; + [_shortcuts removeObjectForKey:defaultsKeyName]; + [_actions removeObjectForKey:defaultsKeyName]; + [self unbind:defaultsKeyName]; +} + +- (void) registerDefaultShortcuts: (NSDictionary*) defaultShortcuts +{ + NSValueTransformer *transformer = [_bindingOptions valueForKey:NSValueTransformerBindingOption]; + if (transformer == nil) { + NSString *transformerName = [_bindingOptions valueForKey:NSValueTransformerNameBindingOption]; + if (transformerName) { + transformer = [NSValueTransformer valueTransformerForName:transformerName]; + } + } + + NSAssert(transformer != nil, @"Can’t register default shortcuts without a transformer."); + + [defaultShortcuts enumerateKeysAndObjectsUsingBlock:^(NSString *defaultsKey, MASShortcut *shortcut, BOOL *stop) { + id value = [transformer reverseTransformedValue:shortcut]; + [[NSUserDefaults standardUserDefaults] registerDefaults:@{defaultsKey:value}]; + }]; +} + +#pragma mark Bindings + +- (BOOL) isRegisteredAction: (NSString*) name +{ + return !![_actions objectForKey:name]; +} + +- (id) valueForUndefinedKey: (NSString*) key +{ + return [self isRegisteredAction:key] ? + [_shortcuts objectForKey:key] : + [super valueForUndefinedKey:key]; +} + +- (void) setValue: (id) value forUndefinedKey: (NSString*) key +{ + if (![self isRegisteredAction:key]) { + [super setValue:value forUndefinedKey:key]; + return; + } + + MASShortcut *newShortcut = value; + MASShortcut *currentShortcut = [_shortcuts objectForKey:key]; + + // Unbind previous shortcut if any + if (currentShortcut != nil) { + [_shortcutMonitor unregisterShortcut:currentShortcut]; + } + + // Just deleting the old shortcut + if (newShortcut == nil) { + return; + } + + // Bind new shortcut + [_shortcuts setObject:newShortcut forKey:key]; + [_shortcutMonitor registerShortcut:newShortcut withAction:[_actions objectForKey:key]]; +} + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcutMonitor.h b/vendor/Pods/MASShortcut/Framework/MASShortcutMonitor.h new file mode 100644 index 0000000..dc3d458 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcutMonitor.h @@ -0,0 +1,27 @@ +#import "MASShortcut.h" + +/** + Executes action when a shortcut is pressed. + + There can only be one instance of this class, otherwise things + will probably not work. (There’s a Carbon event handler inside + and there can only be one Carbon event handler of a given type.) +*/ +@interface MASShortcutMonitor : NSObject + +- (instancetype) init __unavailable; ++ (instancetype) sharedMonitor; + +/** + Register a shortcut along with an action. + + Attempting to insert an already registered shortcut probably won’t work. + It may burn your house or cut your fingers. You have been warned. +*/ +- (BOOL) registerShortcut: (MASShortcut*) shortcut withAction: (dispatch_block_t) action; +- (BOOL) isShortcutRegistered: (MASShortcut*) shortcut; + +- (void) unregisterShortcut: (MASShortcut*) shortcut; +- (void) unregisterAllShortcuts; + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcutMonitor.m b/vendor/Pods/MASShortcut/Framework/MASShortcutMonitor.m new file mode 100644 index 0000000..fce8022 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcutMonitor.m @@ -0,0 +1,108 @@ +#import "MASShortcutMonitor.h" +#import "MASHotKey.h" + +@interface MASShortcutMonitor () +@property(assign) EventHandlerRef eventHandlerRef; +@property(strong) NSMutableDictionary *hotKeys; +@end + +static OSStatus MASCarbonEventCallback(EventHandlerCallRef, EventRef, void*); + +@implementation MASShortcutMonitor + +#pragma mark Initialization + +- (instancetype) init +{ + self = [super init]; + [self setHotKeys:[NSMutableDictionary dictionary]]; + EventTypeSpec hotKeyPressedSpec = { .eventClass = kEventClassKeyboard, .eventKind = kEventHotKeyPressed }; + OSStatus status = InstallEventHandler(GetEventDispatcherTarget(), MASCarbonEventCallback, + 1, &hotKeyPressedSpec, (__bridge void*)self, &_eventHandlerRef); + if (status != noErr) { + return nil; + } + return self; +} + +- (void) dealloc +{ + if (_eventHandlerRef) { + RemoveEventHandler(_eventHandlerRef); + _eventHandlerRef = NULL; + } +} + ++ (instancetype) sharedMonitor +{ + static dispatch_once_t once; + static MASShortcutMonitor *sharedInstance; + dispatch_once(&once, ^{ + sharedInstance = [[self alloc] init]; + }); + return sharedInstance; +} + +#pragma mark Registration + +- (BOOL) registerShortcut: (MASShortcut*) shortcut withAction: (dispatch_block_t) action +{ + MASHotKey *hotKey = [MASHotKey registeredHotKeyWithShortcut:shortcut]; + if (hotKey) { + [hotKey setAction:action]; + [_hotKeys setObject:hotKey forKey:shortcut]; + return YES; + } else { + return NO; + } +} + +- (void) unregisterShortcut: (MASShortcut*) shortcut +{ + if (shortcut) { + [_hotKeys removeObjectForKey:shortcut]; + } +} + +- (void) unregisterAllShortcuts +{ + [_hotKeys removeAllObjects]; +} + +- (BOOL) isShortcutRegistered: (MASShortcut*) shortcut +{ + return !![_hotKeys objectForKey:shortcut]; +} + +#pragma mark Event Handling + +- (void) handleEvent: (EventRef) event +{ + if (GetEventClass(event) != kEventClassKeyboard) { + return; + } + + EventHotKeyID hotKeyID; + OSStatus status = GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(hotKeyID), NULL, &hotKeyID); + if (status != noErr || hotKeyID.signature != MASHotKeySignature) { + return; + } + + [_hotKeys enumerateKeysAndObjectsUsingBlock:^(MASShortcut *shortcut, MASHotKey *hotKey, BOOL *stop) { + if (hotKeyID.id == [hotKey carbonID]) { + if ([hotKey action]) { + dispatch_async(dispatch_get_main_queue(), [hotKey action]); + } + *stop = YES; + } + }]; +} + +@end + +static OSStatus MASCarbonEventCallback(EventHandlerCallRef _, EventRef event, void *context) +{ + MASShortcutMonitor *dispatcher = (__bridge id)context; + [dispatcher handleEvent:event]; + return noErr; +} diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcutValidator.h b/vendor/Pods/MASShortcut/Framework/MASShortcutValidator.h new file mode 100644 index 0000000..cc5f816 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcutValidator.h @@ -0,0 +1,15 @@ +#import "MASShortcut.h" + +@interface MASShortcutValidator : NSObject + +// The following API enable hotkeys with the Option key as the only modifier +// For example, Option-G will not generate © and Option-R will not paste ® +@property(assign) BOOL allowAnyShortcutWithOptionModifier; + ++ (instancetype) sharedValidator; + +- (BOOL) isShortcutValid: (MASShortcut*) shortcut; +- (BOOL) isShortcut: (MASShortcut*) shortcut alreadyTakenInMenu: (NSMenu*) menu explanation: (NSString**) explanation; +- (BOOL) isShortcutAlreadyTakenBySystem: (MASShortcut*) shortcut explanation: (NSString**) explanation; + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcutValidator.m b/vendor/Pods/MASShortcut/Framework/MASShortcutValidator.m new file mode 100644 index 0000000..47dd700 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcutValidator.m @@ -0,0 +1,111 @@ +#import "MASShortcutValidator.h" + +@implementation MASShortcutValidator + ++ (instancetype) sharedValidator +{ + static dispatch_once_t once; + static MASShortcutValidator *sharedInstance; + dispatch_once(&once, ^{ + sharedInstance = [[self alloc] init]; + }); + return sharedInstance; +} + +- (BOOL) isShortcutValid: (MASShortcut*) shortcut +{ + NSUInteger keyCode = [shortcut keyCode]; + NSUInteger modifiers = [shortcut modifierFlags]; + + // Allow any function key with any combination of modifiers + BOOL includesFunctionKey = ((keyCode == kVK_F1) || (keyCode == kVK_F2) || (keyCode == kVK_F3) || (keyCode == kVK_F4) || + (keyCode == kVK_F5) || (keyCode == kVK_F6) || (keyCode == kVK_F7) || (keyCode == kVK_F8) || + (keyCode == kVK_F9) || (keyCode == kVK_F10) || (keyCode == kVK_F11) || (keyCode == kVK_F12) || + (keyCode == kVK_F13) || (keyCode == kVK_F14) || (keyCode == kVK_F15) || (keyCode == kVK_F16) || + (keyCode == kVK_F17) || (keyCode == kVK_F18) || (keyCode == kVK_F19) || (keyCode == kVK_F20)); + if (includesFunctionKey) return YES; + + // Do not allow any other key without modifiers + BOOL hasModifierFlags = (modifiers > 0); + if (!hasModifierFlags) return NO; + + // Allow any hotkey containing Control or Command modifier + BOOL includesCommand = ((modifiers & NSCommandKeyMask) > 0); + BOOL includesControl = ((modifiers & NSControlKeyMask) > 0); + if (includesCommand || includesControl) return YES; + + // Allow Option key only in selected cases + BOOL includesOption = ((modifiers & NSAlternateKeyMask) > 0); + if (includesOption) { + + // Always allow Option-Space and Option-Escape because they do not have any bind system commands + if ((keyCode == kVK_Space) || (keyCode == kVK_Escape)) return YES; + + // Allow Option modifier with any key even if it will break the system binding + if (_allowAnyShortcutWithOptionModifier) return YES; + } + + // The hotkey does not have any modifiers or violates system bindings + return NO; +} + +- (BOOL) isShortcut: (MASShortcut*) shortcut alreadyTakenInMenu: (NSMenu*) menu explanation: (NSString**) explanation +{ + NSString *keyEquivalent = [shortcut keyCodeStringForKeyEquivalent]; + NSUInteger flags = [shortcut modifierFlags]; + + for (NSMenuItem *menuItem in menu.itemArray) { + if (menuItem.hasSubmenu && [self isShortcut:shortcut alreadyTakenInMenu:[menuItem submenu] explanation:explanation]) return YES; + + BOOL equalFlags = (MASPickCocoaModifiers(menuItem.keyEquivalentModifierMask) == flags); + BOOL equalHotkeyLowercase = [menuItem.keyEquivalent.lowercaseString isEqualToString:keyEquivalent]; + + // Check if the cases are different, we know ours is lower and that shift is included in our modifiers + // If theirs is capitol, we need to add shift to their modifiers + if (equalHotkeyLowercase && ![menuItem.keyEquivalent isEqualToString:keyEquivalent]) { + equalFlags = (MASPickCocoaModifiers(menuItem.keyEquivalentModifierMask | NSShiftKeyMask) == flags); + } + + if (equalFlags && equalHotkeyLowercase) { + if (explanation) { + *explanation = NSLocalizedString(@"This shortcut cannot be used because it is already used by the menu item ‘%@’.", + @"Message for alert when shortcut is already used"); + *explanation = [NSString stringWithFormat:*explanation, menuItem.title]; + } + return YES; + } + } + return NO; +} + +- (BOOL) isShortcutAlreadyTakenBySystem: (MASShortcut*) shortcut explanation: (NSString**) explanation +{ + CFArrayRef globalHotKeys; + if (CopySymbolicHotKeys(&globalHotKeys) == noErr) { + + // Enumerate all global hotkeys and check if any of them matches current shortcut + for (CFIndex i = 0, count = CFArrayGetCount(globalHotKeys); i < count; i++) { + CFDictionaryRef hotKeyInfo = CFArrayGetValueAtIndex(globalHotKeys, i); + CFNumberRef code = CFDictionaryGetValue(hotKeyInfo, kHISymbolicHotKeyCode); + CFNumberRef flags = CFDictionaryGetValue(hotKeyInfo, kHISymbolicHotKeyModifiers); + CFNumberRef enabled = CFDictionaryGetValue(hotKeyInfo, kHISymbolicHotKeyEnabled); + + if (([(__bridge NSNumber *)code unsignedIntegerValue] == [shortcut keyCode]) && + ([(__bridge NSNumber *)flags unsignedIntegerValue] == [shortcut carbonFlags]) && + ([(__bridge NSNumber *)enabled boolValue])) { + + if (explanation) { + *explanation = NSLocalizedString(@"This combination cannot be used because it is already used by a system-wide " + @"keyboard shortcut.\nIf you really want to use this key combination, most shortcuts " + @"can be changed in the Keyboard & Mouse panel in System Preferences.", + @"Message for alert when shortcut is already used by the system"); + } + return YES; + } + } + CFRelease(globalHotKeys); + } + return [self isShortcut:shortcut alreadyTakenInMenu:[NSApp mainMenu] explanation:explanation]; +} + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcutView+Bindings.h b/vendor/Pods/MASShortcut/Framework/MASShortcutView+Bindings.h new file mode 100644 index 0000000..01b2246 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcutView+Bindings.h @@ -0,0 +1,25 @@ +#import "MASShortcutView.h" + +/** + A simplified interface to bind the recorder value to user defaults. + + You can bind the `shortcutValue` to user defaults using the standard + `bind:toObject:withKeyPath:options:` call, but since that’s a lot to type + and read, here’s a simpler option. + + Setting the `associatedUserDefaultsKey` binds the view’s shortcut value + to the given user defaults key. You can supply a value transformer to convert + values between user defaults and `MASShortcut`. If you don’t supply + a transformer, the `NSUnarchiveFromDataTransformerName` will be used + automatically. + + Set `associatedUserDefaultsKey` to `nil` to disconnect the binding. +*/ +@interface MASShortcutView (Bindings) + +@property(copy) NSString *associatedUserDefaultsKey; + +- (void) setAssociatedUserDefaultsKey: (NSString*) newKey withTransformer: (NSValueTransformer*) transformer; +- (void) setAssociatedUserDefaultsKey: (NSString*) newKey withTransformerName: (NSString*) transformerName; + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcutView+Bindings.m b/vendor/Pods/MASShortcut/Framework/MASShortcutView+Bindings.m new file mode 100644 index 0000000..54c5111 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcutView+Bindings.m @@ -0,0 +1,50 @@ +#import "MASShortcutView+Bindings.h" + +@implementation MASShortcutView (Bindings) + +- (NSString*) associatedUserDefaultsKey +{ + NSDictionary* bindingInfo = [self infoForBinding:MASShortcutBinding]; + if (bindingInfo != nil) { + NSString *keyPath = [bindingInfo objectForKey:NSObservedKeyPathKey]; + NSString *key = [keyPath stringByReplacingOccurrencesOfString:@"values." withString:@""]; + return key; + } else { + return nil; + } +} + +- (void) setAssociatedUserDefaultsKey: (NSString*) newKey withTransformer: (NSValueTransformer*) transformer +{ + // Break previous binding if any + NSString *currentKey = [self associatedUserDefaultsKey]; + if (currentKey != nil) { + [self unbind:currentKey]; + } + + // Stop if the new binding is nil + if (newKey == nil) { + return; + } + + NSDictionary *options = transformer ? + @{NSValueTransformerBindingOption:transformer} : + nil; + + [self bind:MASShortcutBinding + toObject:[NSUserDefaultsController sharedUserDefaultsController] + withKeyPath:[@"values." stringByAppendingString:newKey] + options:options]; +} + +- (void) setAssociatedUserDefaultsKey: (NSString*) newKey withTransformerName: (NSString*) transformerName +{ + [self setAssociatedUserDefaultsKey:newKey withTransformer:[NSValueTransformer valueTransformerForName:transformerName]]; +} + +- (void) setAssociatedUserDefaultsKey: (NSString*) newKey +{ + [self setAssociatedUserDefaultsKey:newKey withTransformerName:NSKeyedUnarchiveFromDataTransformerName]; +} + +@end diff --git a/vendor/Pods/MASShortcut/Framework/MASShortcutView.h b/vendor/Pods/MASShortcut/Framework/MASShortcutView.h new file mode 100644 index 0000000..166be44 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/MASShortcutView.h @@ -0,0 +1,24 @@ +@class MASShortcut, MASShortcutValidator; + +extern NSString *const MASShortcutBinding; + +typedef enum { + MASShortcutViewStyleDefault = 0, // Height = 19 px + MASShortcutViewStyleTexturedRect, // Height = 25 px + MASShortcutViewStyleRounded, // Height = 43 px + MASShortcutViewStyleFlat +} MASShortcutViewStyle; + +@interface MASShortcutView : NSView + +@property (nonatomic, strong) MASShortcut *shortcutValue; +@property (nonatomic, strong) MASShortcutValidator *shortcutValidator; +@property (nonatomic, getter = isRecording) BOOL recording; +@property (nonatomic, getter = isEnabled) BOOL enabled; +@property (nonatomic, copy) void (^shortcutValueChange)(MASShortcutView *sender); +@property (nonatomic, assign) MASShortcutViewStyle style; + +/// Returns custom class for drawing control. ++ (Class)shortcutCellClass; + +@end diff --git a/vendor/Pods/MASShortcut/MASShortcutView.m b/vendor/Pods/MASShortcut/Framework/MASShortcutView.m similarity index 67% rename from vendor/Pods/MASShortcut/MASShortcutView.m rename to vendor/Pods/MASShortcut/Framework/MASShortcutView.m index ba28e47..d521880 100644 --- a/vendor/Pods/MASShortcut/MASShortcutView.m +++ b/vendor/Pods/MASShortcut/Framework/MASShortcutView.m @@ -1,5 +1,7 @@ #import "MASShortcutView.h" -#import "MASShortcut.h" +#import "MASShortcutValidator.h" + +NSString *const MASShortcutBinding = @"shortcutValue"; #define HINT_BUTTON_WIDTH 23.0 #define BUTTON_FONT_SIZE 11.0 @@ -23,14 +25,6 @@ @implementation MASShortcutView { NSTrackingArea *_hintArea; } -@synthesize enabled = _enabled; -@synthesize hinting = _hinting; -@synthesize shortcutValue = _shortcutValue; -@synthesize shortcutPlaceholder = _shortcutPlaceholder; -@synthesize shortcutValueChange = _shortcutValueChange; -@synthesize recording = _recording; -@synthesize appearance = _appearance; - #pragma mark - + (Class)shortcutCellClass @@ -42,15 +36,30 @@ - (id)initWithFrame:(CGRect)frameRect { self = [super initWithFrame:frameRect]; if (self) { - _shortcutCell = [[[self.class shortcutCellClass] alloc] init]; - _shortcutCell.buttonType = NSPushOnPushOffButton; - _shortcutCell.font = [[NSFontManager sharedFontManager] convertFont:_shortcutCell.font toSize:BUTTON_FONT_SIZE]; - _enabled = YES; - [self resetShortcutCellStyle]; + [self commonInit]; + } + return self; +} + +- (id)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + [self commonInit]; } return self; } +- (void)commonInit +{ + _shortcutCell = [[[self.class shortcutCellClass] alloc] init]; + _shortcutCell.buttonType = NSPushOnPushOffButton; + _shortcutCell.font = [[NSFontManager sharedFontManager] convertFont:_shortcutCell.font toSize:BUTTON_FONT_SIZE]; + _shortcutValidator = [MASShortcutValidator sharedValidator]; + _enabled = YES; + [self resetShortcutCellStyle]; +} + - (void)dealloc { [self activateEventMonitoring:NO]; @@ -69,10 +78,10 @@ - (void)setEnabled:(BOOL)flag } } -- (void)setAppearance:(MASShortcutViewAppearance)appearance +- (void)setStyle:(MASShortcutViewStyle)newStyle { - if (_appearance != appearance) { - _appearance = appearance; + if (_style != newStyle) { + _style = newStyle; [self resetShortcutCellStyle]; [self setNeedsDisplay:YES]; } @@ -80,19 +89,25 @@ - (void)setAppearance:(MASShortcutViewAppearance)appearance - (void)resetShortcutCellStyle { - switch (_appearance) { - case MASShortcutViewAppearanceDefault: { + switch (_style) { + case MASShortcutViewStyleDefault: { _shortcutCell.bezelStyle = NSRoundRectBezelStyle; break; } - case MASShortcutViewAppearanceTexturedRect: { + case MASShortcutViewStyleTexturedRect: { _shortcutCell.bezelStyle = NSTexturedRoundedBezelStyle; break; } - case MASShortcutViewAppearanceRounded: { + case MASShortcutViewStyleRounded: { _shortcutCell.bezelStyle = NSRoundedBezelStyle; break; } + case MASShortcutViewStyleFlat: { + self.wantsLayer = YES; + _shortcutCell.backgroundColor = [NSColor clearColor]; + _shortcutCell.bordered = NO; + break; + } } } @@ -123,6 +138,7 @@ - (void)setShortcutValue:(MASShortcut *)shortcutValue _shortcutValue = shortcutValue; [self resetToolTips]; [self setNeedsDisplay:YES]; + [self propagateValue:shortcutValue forBinding:@"shortcutValue"]; if (self.shortcutValueChange) { self.shortcutValueChange(self); @@ -149,26 +165,30 @@ - (void)drawInRect:(CGRect)frame withTitle:(NSString *)title alignment:(NSTextAl _shortcutCell.state = state; _shortcutCell.enabled = self.enabled; - switch (_appearance) { - case MASShortcutViewAppearanceDefault: { + switch (_style) { + case MASShortcutViewStyleDefault: { [_shortcutCell drawWithFrame:frame inView:self]; break; } - case MASShortcutViewAppearanceTexturedRect: { + case MASShortcutViewStyleTexturedRect: { [_shortcutCell drawWithFrame:CGRectOffset(frame, 0.0, 1.0) inView:self]; break; } - case MASShortcutViewAppearanceRounded: { + case MASShortcutViewStyleRounded: { [_shortcutCell drawWithFrame:CGRectOffset(frame, 0.0, 1.0) inView:self]; break; } + case MASShortcutViewStyleFlat: { + [_shortcutCell drawWithFrame:frame inView:self]; + break; + } } } - (void)drawRect:(CGRect)dirtyRect { if (self.shortcutValue) { - [self drawInRect:self.bounds withTitle:MASShortcutChar(self.recording ? kMASShortcutGlyphEscape : kMASShortcutGlyphDeleteLeft) + [self drawInRect:self.bounds withTitle:NSStringFromMASKeyCode(self.recording ? kMASShortcutGlyphEscape : kMASShortcutGlyphClear) alignment:NSRightTextAlignment state:NSOffState]; CGRect shortcutRect; @@ -185,7 +205,7 @@ - (void)drawRect:(CGRect)dirtyRect else { if (self.recording) { - [self drawInRect:self.bounds withTitle:MASShortcutChar(kMASShortcutGlyphEscape) alignment:NSRightTextAlignment state:NSOffState]; + [self drawInRect:self.bounds withTitle:NSStringFromMASKeyCode(kMASShortcutGlyphEscape) alignment:NSRightTextAlignment state:NSOffState]; CGRect shortcutRect; [self getShortcutRect:&shortcutRect hintRect:NULL]; @@ -210,9 +230,10 @@ - (void)getShortcutRect:(CGRect *)shortcutRectRef hintRect:(CGRect *)hintRectRef { CGRect shortcutRect, hintRect; CGFloat hintButtonWidth = HINT_BUTTON_WIDTH; - switch (self.appearance) { - case MASShortcutViewAppearanceTexturedRect: hintButtonWidth += 2.0; break; - case MASShortcutViewAppearanceRounded: hintButtonWidth += 3.0; break; + switch (self.style) { + case MASShortcutViewStyleTexturedRect: hintButtonWidth += 2.0; break; + case MASShortcutViewStyleRounded: hintButtonWidth += 3.0; break; + case MASShortcutViewStyleFlat: hintButtonWidth -= 8.0 - (_shortcutCell.font.pointSize - BUTTON_FONT_SIZE); break; default: break; } CGRectDivide(self.bounds, &hintRect, &shortcutRect, hintButtonWidth, CGRectMaxXEdge); @@ -348,41 +369,50 @@ - (void)activateEventMonitoring:(BOOL)shouldActivate static id eventMonitor = nil; if (shouldActivate) { - __weak MASShortcutView *weakSelf = self; + __unsafe_unretained MASShortcutView *weakSelf = self; NSEventMask eventMask = (NSKeyDownMask | NSFlagsChangedMask); eventMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^(NSEvent *event) { + // Create a shortcut from the event MASShortcut *shortcut = [MASShortcut shortcutWithEvent:event]; - if ((shortcut.keyCode == kVK_Delete) || (shortcut.keyCode == kVK_ForwardDelete)) { - // Delete shortcut + + // If the shortcut is a plain Delete or Backspace, clear the current shortcut and cancel recording + if (!shortcut.modifierFlags && ((shortcut.keyCode == kVK_Delete) || (shortcut.keyCode == kVK_ForwardDelete))) { weakSelf.shortcutValue = nil; weakSelf.recording = NO; event = nil; } - else if (shortcut.keyCode == kVK_Escape) { - // Cancel recording + + // If the shortcut is a plain Esc, cancel recording + else if (!shortcut.modifierFlags && shortcut.keyCode == kVK_Escape) { weakSelf.recording = NO; event = nil; } - else if (shortcut.shouldBypass) { - // Command + W, Command + Q, ESC should deactivate recorder + + // If the shortcut is Cmd-W or Cmd-Q, cancel recording and pass the event through + else if ((shortcut.modifierFlags == NSCommandKeyMask) && (shortcut.keyCode == kVK_ANSI_W || shortcut.keyCode == kVK_ANSI_Q)) { weakSelf.recording = NO; } + else { // Verify possible shortcut if (shortcut.keyCodeString.length > 0) { - if (shortcut.valid) { + if ([_shortcutValidator isShortcutValid:shortcut]) { // Verify that shortcut is not used - NSError *error = nil; - if ([shortcut isTakenError:&error]) { + NSString *explanation = nil; + if ([_shortcutValidator isShortcutAlreadyTakenBySystem:shortcut explanation:&explanation]) { // Prevent cancel of recording when Alert window is key [weakSelf activateResignObserver:NO]; [weakSelf activateEventMonitoring:NO]; NSString *format = NSLocalizedString(@"The key combination %@ cannot be used", @"Title for alert when shortcut is already used"); - NSRunCriticalAlertPanel([NSString stringWithFormat:format, shortcut], error.localizedDescription, - NSLocalizedString(@"OK", @"Alert button when shortcut is already used"), - nil, nil); + NSAlert* alert = [[NSAlert alloc]init]; + alert.alertStyle = NSCriticalAlertStyle; + alert.informativeText = explanation; + alert.messageText = [NSString stringWithFormat:format, shortcut]; + [alert addButtonWithTitle:NSLocalizedString(@"OK", @"Alert button when shortcut is already used")]; + + [alert runModal]; weakSelf.shortcutPlaceholder = nil; [weakSelf activateResignObserver:YES]; [weakSelf activateEventMonitoring:YES]; @@ -420,7 +450,7 @@ - (void)activateResignObserver:(BOOL)shouldActivate static id observer = nil; NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; if (shouldActivate) { - __weak MASShortcutView *weakSelf = self; + __unsafe_unretained MASShortcutView *weakSelf = self; observer = [notificationCenter addObserverForName:NSWindowDidResignKeyNotification object:self.window queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { weakSelf.recording = NO; @@ -431,4 +461,51 @@ - (void)activateResignObserver:(BOOL)shouldActivate } } +#pragma mark Bindings + +// http://tomdalling.com/blog/cocoa/implementing-your-own-cocoa-bindings/ +-(void) propagateValue:(id)value forBinding:(NSString*)binding; +{ + NSParameterAssert(binding != nil); + + //WARNING: bindingInfo contains NSNull, so it must be accounted for + NSDictionary* bindingInfo = [self infoForBinding:binding]; + if(!bindingInfo) + return; //there is no binding + + //apply the value transformer, if one has been set + NSDictionary* bindingOptions = [bindingInfo objectForKey:NSOptionsKey]; + if(bindingOptions){ + NSValueTransformer* transformer = [bindingOptions valueForKey:NSValueTransformerBindingOption]; + if(!transformer || (id)transformer == [NSNull null]){ + NSString* transformerName = [bindingOptions valueForKey:NSValueTransformerNameBindingOption]; + if(transformerName && (id)transformerName != [NSNull null]){ + transformer = [NSValueTransformer valueTransformerForName:transformerName]; + } + } + + if(transformer && (id)transformer != [NSNull null]){ + if([[transformer class] allowsReverseTransformation]){ + value = [transformer reverseTransformedValue:value]; + } else { + NSLog(@"WARNING: binding \"%@\" has value transformer, but it doesn't allow reverse transformations in %s", binding, __PRETTY_FUNCTION__); + } + } + } + + id boundObject = [bindingInfo objectForKey:NSObservedObjectKey]; + if(!boundObject || boundObject == [NSNull null]){ + NSLog(@"ERROR: NSObservedObjectKey was nil for binding \"%@\" in %s", binding, __PRETTY_FUNCTION__); + return; + } + + NSString* boundKeyPath = [bindingInfo objectForKey:NSObservedKeyPathKey]; + if(!boundKeyPath || (id)boundKeyPath == [NSNull null]){ + NSLog(@"ERROR: NSObservedKeyPathKey was nil for binding \"%@\" in %s", binding, __PRETTY_FUNCTION__); + return; + } + + [boundObject setValue:value forKeyPath:boundKeyPath]; +} + @end diff --git a/vendor/Pods/MASShortcut/Framework/Shortcut.h b/vendor/Pods/MASShortcut/Framework/Shortcut.h new file mode 100644 index 0000000..e131395 --- /dev/null +++ b/vendor/Pods/MASShortcut/Framework/Shortcut.h @@ -0,0 +1,7 @@ +#import "MASShortcut.h" +#import "MASShortcutValidator.h" +#import "MASShortcutMonitor.h" +#import "MASShortcutBinder.h" +#import "MASDictionaryTransformer.h" +#import "MASShortcutView.h" +#import "MASShortcutView+Bindings.h" \ No newline at end of file diff --git a/vendor/Pods/MASShortcut/MASShortcut+Monitoring.h b/vendor/Pods/MASShortcut/MASShortcut+Monitoring.h deleted file mode 100644 index aa8f224..0000000 --- a/vendor/Pods/MASShortcut/MASShortcut+Monitoring.h +++ /dev/null @@ -1,8 +0,0 @@ -#import "MASShortcut.h" - -@interface MASShortcut (Monitoring) - -+ (id)addGlobalHotkeyMonitorWithShortcut:(MASShortcut *)shortcut handler:(void (^)())handler; -+ (void)removeGlobalHotkeyMonitor:(id)monitor; - -@end diff --git a/vendor/Pods/MASShortcut/MASShortcut+Monitoring.m b/vendor/Pods/MASShortcut/MASShortcut+Monitoring.m deleted file mode 100644 index bd0282b..0000000 --- a/vendor/Pods/MASShortcut/MASShortcut+Monitoring.m +++ /dev/null @@ -1,165 +0,0 @@ -#import "MASShortcut+Monitoring.h" - -NSMutableDictionary *MASRegisteredHotKeys(); -BOOL InstallCommonEventHandler(); -BOOL InstallHotkeyWithShortcut(MASShortcut *shortcut, UInt32 *outCarbonHotKeyID, EventHotKeyRef *outCarbonHotKey); -void UninstallEventHandler(); - -#pragma mark - - -@interface MASShortcutHotKey : NSObject - -@property (nonatomic, readonly) MASShortcut *shortcut; -@property (nonatomic, readonly, copy) void (^handler)(); -@property (nonatomic, readonly) EventHotKeyRef carbonHotKey; -@property (nonatomic, readonly) UInt32 carbonHotKeyID; - -- (id)initWithShortcut:(MASShortcut *)shortcut handler:(void (^)())handler; - -@end - -#pragma mark - - -@implementation MASShortcut (Monitoring) - -+ (id)addGlobalHotkeyMonitorWithShortcut:(MASShortcut *)shortcut handler:(void (^)())handler -{ - NSString *monitor = [NSString stringWithFormat:@"%@", shortcut.description]; - if ([MASRegisteredHotKeys() objectForKey:monitor]) return nil; - - MASShortcutHotKey *hotKey = [[MASShortcutHotKey alloc] initWithShortcut:shortcut handler:handler]; - if (hotKey == nil) return nil; - - [MASRegisteredHotKeys() setObject:hotKey forKey:monitor]; - return monitor; -} - -+ (void)removeGlobalHotkeyMonitor:(id)monitor -{ - if (monitor == nil) return; - NSMutableDictionary *registeredHotKeys = MASRegisteredHotKeys(); - [registeredHotKeys removeObjectForKey:monitor]; - if (registeredHotKeys.count == 0) { - UninstallEventHandler(); - } -} - -@end - -#pragma mark - - -@implementation MASShortcutHotKey - -@synthesize carbonHotKeyID = _carbonHotKeyID; -@synthesize handler = _handler; -@synthesize shortcut = _shortcut; -@synthesize carbonHotKey = _carbonHotKey; - -#pragma mark - - -- (id)initWithShortcut:(MASShortcut *)shortcut handler:(void (^)())handler -{ - self = [super init]; - if (self) { - _shortcut = shortcut; - _handler = [handler copy]; - - if (!InstallHotkeyWithShortcut(shortcut, &_carbonHotKeyID, &_carbonHotKey)) - self = nil; - } - return self; -} - -- (void)dealloc -{ - [self uninstallExisitingHotKey]; -} - -- (void)uninstallExisitingHotKey -{ - if (_carbonHotKey) { - UnregisterEventHotKey(_carbonHotKey); - _carbonHotKey = NULL; - } -} - -@end - -#pragma mark - Carbon magic - -NSMutableDictionary *MASRegisteredHotKeys() -{ - static NSMutableDictionary *shared = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - shared = [NSMutableDictionary dictionary]; - }); - return shared; -} - -#pragma mark - - -FourCharCode const kMASShortcutSignature = 'MASS'; - -BOOL InstallHotkeyWithShortcut(MASShortcut *shortcut, UInt32 *outCarbonHotKeyID, EventHotKeyRef *outCarbonHotKey) -{ - if ((shortcut == nil) || !InstallCommonEventHandler()) return NO; - - static UInt32 sCarbonHotKeyID = 0; - EventHotKeyID hotKeyID = { .signature = kMASShortcutSignature, .id = ++ sCarbonHotKeyID }; - EventHotKeyRef carbonHotKey = NULL; - if (RegisterEventHotKey(shortcut.carbonKeyCode, shortcut.carbonFlags, hotKeyID, GetEventDispatcherTarget(), kEventHotKeyExclusive, &carbonHotKey) != noErr) { - return NO; - } - - if (outCarbonHotKeyID) *outCarbonHotKeyID = hotKeyID.id; - if (outCarbonHotKey) *outCarbonHotKey = carbonHotKey; - return YES; -} - -static OSStatus CarbonCallback(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) -{ - if (GetEventClass(inEvent) != kEventClassKeyboard) return noErr; - - EventHotKeyID hotKeyID; - OSStatus status = GetEventParameter(inEvent, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(hotKeyID), NULL, &hotKeyID); - if (status != noErr) return status; - - if (hotKeyID.signature != kMASShortcutSignature) return noErr; - - [MASRegisteredHotKeys() enumerateKeysAndObjectsUsingBlock:^(id key, MASShortcutHotKey *hotKey, BOOL *stop) { - if (hotKeyID.id == hotKey.carbonHotKeyID) { - if (hotKey.handler) { - hotKey.handler(); - } - *stop = YES; - } - }]; - - return noErr; -} - -#pragma mark - - -static EventHandlerRef sEventHandler = NULL; - -BOOL InstallCommonEventHandler() -{ - if (sEventHandler == NULL) { - EventTypeSpec hotKeyPressedSpec = { .eventClass = kEventClassKeyboard, .eventKind = kEventHotKeyPressed }; - OSStatus status = InstallEventHandler(GetEventDispatcherTarget(), CarbonCallback, 1, &hotKeyPressedSpec, NULL, &sEventHandler); - if (status != noErr) { - sEventHandler = NULL; - return NO; - } - } - return YES; -} - -void UninstallEventHandler() -{ - if (sEventHandler) { - RemoveEventHandler(sEventHandler); - sEventHandler = NULL; - } -} diff --git a/vendor/Pods/MASShortcut/MASShortcut+UserDefaults.h b/vendor/Pods/MASShortcut/MASShortcut+UserDefaults.h deleted file mode 100644 index 9f2ecb9..0000000 --- a/vendor/Pods/MASShortcut/MASShortcut+UserDefaults.h +++ /dev/null @@ -1,9 +0,0 @@ -#import "MASShortcut.h" - -@interface MASShortcut (UserDefaults) - -+ (void)registerGlobalShortcutWithUserDefaultsKey:(NSString *)userDefaultsKey handler:(void (^)())handler; -+ (void)unregisterGlobalShortcutWithUserDefaultsKey:(NSString *)userDefaultsKey; -+ (void)setGlobalShortcut:(MASShortcut *)shortcut forUserDefaultsKey:(NSString *)userDefaultsKey; - -@end diff --git a/vendor/Pods/MASShortcut/MASShortcut+UserDefaults.m b/vendor/Pods/MASShortcut/MASShortcut+UserDefaults.m deleted file mode 100644 index ac4fc3d..0000000 --- a/vendor/Pods/MASShortcut/MASShortcut+UserDefaults.m +++ /dev/null @@ -1,104 +0,0 @@ -#import "MASShortcut+UserDefaults.h" -#import "MASShortcut+Monitoring.h" - -@interface MASShortcutUserDefaultsHotKey : NSObject - -@property (nonatomic, readonly) NSString *userDefaultsKey; -@property (nonatomic, copy) void (^handler)(); -@property (nonatomic, weak) id monitor; - -- (id)initWithUserDefaultsKey:(NSString *)userDefaultsKey handler:(void (^)())handler; - -@end - -#pragma mark - - -@implementation MASShortcut (UserDefaults) - -+ (NSMutableDictionary *)registeredUserDefaultsHotKeys -{ - static NSMutableDictionary *shared = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - shared = [NSMutableDictionary dictionary]; - }); - return shared; -} - -+ (void)registerGlobalShortcutWithUserDefaultsKey:(NSString *)userDefaultsKey handler:(void (^)())handler; -{ - MASShortcutUserDefaultsHotKey *hotKey = [[MASShortcutUserDefaultsHotKey alloc] initWithUserDefaultsKey:userDefaultsKey handler:handler]; - [[self registeredUserDefaultsHotKeys] setObject:hotKey forKey:userDefaultsKey]; -} - -+ (void)unregisterGlobalShortcutWithUserDefaultsKey:(NSString *)userDefaultsKey -{ - NSMutableDictionary *registeredHotKeys = [self registeredUserDefaultsHotKeys]; - [registeredHotKeys removeObjectForKey:userDefaultsKey]; -} - -+ (void)setGlobalShortcut:(MASShortcut *)shortcut forUserDefaultsKey:(NSString *)userDefaultsKey -{ - NSData *shortcutData = shortcut.data; - if (shortcutData) - [[NSUserDefaults standardUserDefaults] setObject:shortcutData forKey:userDefaultsKey]; - else - [[NSUserDefaults standardUserDefaults] removeObjectForKey:userDefaultsKey]; -} - -@end - -#pragma mark - - -@implementation MASShortcutUserDefaultsHotKey { - NSString *_observableKeyPath; -} - -@synthesize monitor = _monitor; -@synthesize handler = _handler; -@synthesize userDefaultsKey = _userDefaultsKey; - -#pragma mark - - -void *MASShortcutUserDefaultsContext = &MASShortcutUserDefaultsContext; - -- (id)initWithUserDefaultsKey:(NSString *)userDefaultsKey handler:(void (^)())handler -{ - self = [super init]; - if (self) { - _userDefaultsKey = userDefaultsKey.copy; - _handler = [handler copy]; - _observableKeyPath = [@"values." stringByAppendingString:_userDefaultsKey]; - [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:_observableKeyPath options:NSKeyValueObservingOptionInitial context:MASShortcutUserDefaultsContext]; - } - return self; -} - -- (void)dealloc -{ - [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:_observableKeyPath context:MASShortcutUserDefaultsContext]; - [MASShortcut removeGlobalHotkeyMonitor:self.monitor]; -} - -#pragma mark - - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ - if (context == MASShortcutUserDefaultsContext) { - [MASShortcut removeGlobalHotkeyMonitor:self.monitor]; - [self installHotKeyFromUserDefaults]; - } - else { - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; - } -} - -- (void)installHotKeyFromUserDefaults -{ - NSData *data = [[NSUserDefaults standardUserDefaults] dataForKey:_userDefaultsKey]; - MASShortcut *shortcut = [MASShortcut shortcutWithData:data]; - if (shortcut == nil) return; - self.monitor = [MASShortcut addGlobalHotkeyMonitorWithShortcut:shortcut handler:self.handler]; -} - -@end diff --git a/vendor/Pods/MASShortcut/MASShortcut.h b/vendor/Pods/MASShortcut/MASShortcut.h deleted file mode 100644 index 06507f6..0000000 --- a/vendor/Pods/MASShortcut/MASShortcut.h +++ /dev/null @@ -1,59 +0,0 @@ -#import - -#define MASShortcutChar(char) [NSString stringWithFormat:@"%C", (unsigned short)(char)] -#define MASShortcutClear(flags) (flags & (NSControlKeyMask | NSShiftKeyMask | NSAlternateKeyMask | NSCommandKeyMask)) -#define MASShortcutCarbonFlags(cocoaFlags) (\ - (cocoaFlags & NSCommandKeyMask ? cmdKey : 0) | \ - (cocoaFlags & NSAlternateKeyMask ? optionKey : 0) | \ - (cocoaFlags & NSControlKeyMask ? controlKey : 0) | \ - (cocoaFlags & NSShiftKeyMask ? shiftKey : 0)) - -// These glyphs are missed in Carbon.h -enum { - kMASShortcutGlyphEject = 0x23CF, - kMASShortcutGlyphClear = 0x2715, - kMASShortcutGlyphDeleteLeft = 0x232B, - kMASShortcutGlyphDeleteRight = 0x2326, - kMASShortcutGlyphLeftArrow = 0x2190, - kMASShortcutGlyphRightArrow = 0x2192, - kMASShortcutGlyphUpArrow = 0x2191, - kMASShortcutGlyphDownArrow = 0x2193, - kMASShortcutGlyphEscape = 0x238B, - kMASShortcutGlyphHelp = 0x003F, - kMASShortcutGlyphPageDown = 0x21DF, - kMASShortcutGlyphPageUp = 0x21DE, - kMASShortcutGlyphTabRight = 0x21E5, - kMASShortcutGlyphReturn = 0x2305, - kMASShortcutGlyphReturnR2L = 0x21A9, - kMASShortcutGlyphPadClear = 0x2327, - kMASShortcutGlyphNorthwestArrow = 0x2196, - kMASShortcutGlyphSoutheastArrow = 0x2198, -} MASShortcutGlyph; - -@interface MASShortcut : NSObject - -@property (nonatomic) NSUInteger keyCode; -@property (nonatomic) NSUInteger modifierFlags; -@property (nonatomic, readonly) UInt32 carbonKeyCode; -@property (nonatomic, readonly) UInt32 carbonFlags; -@property (nonatomic, readonly) NSString *keyCodeString; -@property (nonatomic, readonly) NSString *keyCodeStringForKeyEquivalent; -@property (nonatomic, readonly) NSString *modifierFlagsString; -@property (nonatomic, readonly) NSData *data; -@property (nonatomic, readonly) BOOL shouldBypass; -@property (nonatomic, readonly, getter = isValid) BOOL valid; - -- (id)initWithKeyCode:(NSUInteger)code modifierFlags:(NSUInteger)flags; - -+ (MASShortcut *)shortcutWithKeyCode:(NSUInteger)code modifierFlags:(NSUInteger)flags; -+ (MASShortcut *)shortcutWithEvent:(NSEvent *)anEvent; -+ (MASShortcut *)shortcutWithData:(NSData *)aData; - -- (BOOL)isTakenError:(NSError **)error; - -// The following API enable hotkeys with the Option key as the only modifier -// For example, Option-G will not generate © and Option-R will not paste ® -+ (void)setAllowsAnyHotkeyWithOptionModifier:(BOOL)allow; -+ (BOOL)allowsAnyHotkeyWithOptionModifier; - -@end diff --git a/vendor/Pods/MASShortcut/MASShortcut.m b/vendor/Pods/MASShortcut/MASShortcut.m deleted file mode 100644 index f03be0e..0000000 --- a/vendor/Pods/MASShortcut/MASShortcut.m +++ /dev/null @@ -1,345 +0,0 @@ -#import "MASShortcut.h" - -NSString *const MASShortcutKeyCode = @"KeyCode"; -NSString *const MASShortcutModifierFlags = @"ModifierFlags"; - -@implementation MASShortcut { - NSUInteger _keyCode; // NSNotFound if empty - NSUInteger _modifierFlags; // 0 if empty -} - -@synthesize modifierFlags = _modifierFlags; -@synthesize keyCode = _keyCode; - -#pragma mark - - -- (void)encodeWithCoder:(NSCoder *)coder -{ - [coder encodeInteger:(self.keyCode != NSNotFound ? (NSInteger)self.keyCode : - 1) forKey:MASShortcutKeyCode]; - [coder encodeInteger:(NSInteger)self.modifierFlags forKey:MASShortcutModifierFlags]; -} - -- (id)initWithCoder:(NSCoder *)decoder -{ - self = [super init]; - if (self) { - NSInteger code = [decoder decodeIntegerForKey:MASShortcutKeyCode]; - self.keyCode = (code < 0 ? NSNotFound : (NSUInteger)code); - self.modifierFlags = [decoder decodeIntegerForKey:MASShortcutModifierFlags]; - } - return self; -} - -- (id)initWithKeyCode:(NSUInteger)code modifierFlags:(NSUInteger)flags -{ - self = [super init]; - if (self) { - _keyCode = code; - _modifierFlags = MASShortcutClear(flags); - } - return self; -} - -+ (MASShortcut *)shortcutWithKeyCode:(NSUInteger)code modifierFlags:(NSUInteger)flags -{ - return [[self alloc] initWithKeyCode:code modifierFlags:flags]; -} - -+ (MASShortcut *)shortcutWithEvent:(NSEvent *)event -{ - return [[self alloc] initWithKeyCode:event.keyCode modifierFlags:event.modifierFlags]; -} - -+ (MASShortcut *)shortcutWithData:(NSData *)data -{ - id shortcut = (data ? [NSKeyedUnarchiver unarchiveObjectWithData:data] : nil); - return shortcut; -} - -#pragma mark - Shortcut accessors - -- (NSData *)data -{ - return [NSKeyedArchiver archivedDataWithRootObject:self]; -} - -- (void)setModifierFlags:(NSUInteger)value -{ - _modifierFlags = MASShortcutClear(value); -} - -- (UInt32)carbonKeyCode -{ - return (self.keyCode == NSNotFound ? 0 : (UInt32)self.keyCode); -} - -- (UInt32)carbonFlags -{ - return MASShortcutCarbonFlags(self.modifierFlags); -} - -- (NSString *)description -{ - return [NSString stringWithFormat:@"%@%@", self.modifierFlagsString, self.keyCodeString]; -} - -- (NSString *)keyCodeStringForKeyEquivalent -{ - NSString *keyCodeString = self.keyCodeString; - if (keyCodeString.length > 1) { - switch (self.keyCode) { - case kVK_F1: return MASShortcutChar(0xF704); - case kVK_F2: return MASShortcutChar(0xF705); - case kVK_F3: return MASShortcutChar(0xF706); - case kVK_F4: return MASShortcutChar(0xF707); - case kVK_F5: return MASShortcutChar(0xF708); - case kVK_F6: return MASShortcutChar(0xF709); - case kVK_F7: return MASShortcutChar(0xF70a); - case kVK_F8: return MASShortcutChar(0xF70b); - case kVK_F9: return MASShortcutChar(0xF70c); - case kVK_F10: return MASShortcutChar(0xF70d); - case kVK_F11: return MASShortcutChar(0xF70e); - case kVK_F12: return MASShortcutChar(0xF70f); - // From this point down I am guessing F13 etc come sequentially, I don't have a keyboard to test. - case kVK_F13: return MASShortcutChar(0xF710); - case kVK_F14: return MASShortcutChar(0xF711); - case kVK_F15: return MASShortcutChar(0xF712); - case kVK_F16: return MASShortcutChar(0xF713); - case kVK_F17: return MASShortcutChar(0xF714); - case kVK_F18: return MASShortcutChar(0xF715); - case kVK_F19: return MASShortcutChar(0xF716); - case kVK_Space: return MASShortcutChar(0x20); - default: return @""; - } - } - return keyCodeString.lowercaseString; -} - -- (NSString *)keyCodeString -{ - // Some key codes don't have an equivalent - switch (self.keyCode) { - case NSNotFound: return @""; - case kVK_F1: return @"F1"; - case kVK_F2: return @"F2"; - case kVK_F3: return @"F3"; - case kVK_F4: return @"F4"; - case kVK_F5: return @"F5"; - case kVK_F6: return @"F6"; - case kVK_F7: return @"F7"; - case kVK_F8: return @"F8"; - case kVK_F9: return @"F9"; - case kVK_F10: return @"F10"; - case kVK_F11: return @"F11"; - case kVK_F12: return @"F12"; - case kVK_F13: return @"F13"; - case kVK_F14: return @"F14"; - case kVK_F15: return @"F15"; - case kVK_F16: return @"F16"; - case kVK_F17: return @"F17"; - case kVK_F18: return @"F18"; - case kVK_F19: return @"F19"; - case kVK_Space: return NSLocalizedString(@"Space", @"Shortcut glyph name for SPACE key"); - case kVK_Escape: return MASShortcutChar(kMASShortcutGlyphEscape); - case kVK_Delete: return MASShortcutChar(kMASShortcutGlyphDeleteLeft); - case kVK_ForwardDelete: return MASShortcutChar(kMASShortcutGlyphDeleteRight); - case kVK_LeftArrow: return MASShortcutChar(kMASShortcutGlyphLeftArrow); - case kVK_RightArrow: return MASShortcutChar(kMASShortcutGlyphRightArrow); - case kVK_UpArrow: return MASShortcutChar(kMASShortcutGlyphUpArrow); - case kVK_DownArrow: return MASShortcutChar(kMASShortcutGlyphDownArrow); - case kVK_Help: return MASShortcutChar(kMASShortcutGlyphHelp); - case kVK_PageUp: return MASShortcutChar(kMASShortcutGlyphPageUp); - case kVK_PageDown: return MASShortcutChar(kMASShortcutGlyphPageDown); - case kVK_Tab: return MASShortcutChar(kMASShortcutGlyphTabRight); - case kVK_Return: return MASShortcutChar(kMASShortcutGlyphReturnR2L); - - // Keypad - case kVK_ANSI_Keypad0: return @"0"; - case kVK_ANSI_Keypad1: return @"1"; - case kVK_ANSI_Keypad2: return @"2"; - case kVK_ANSI_Keypad3: return @"3"; - case kVK_ANSI_Keypad4: return @"4"; - case kVK_ANSI_Keypad5: return @"5"; - case kVK_ANSI_Keypad6: return @"6"; - case kVK_ANSI_Keypad7: return @"7"; - case kVK_ANSI_Keypad8: return @"8"; - case kVK_ANSI_Keypad9: return @"9"; - case kVK_ANSI_KeypadDecimal: return @"."; - case kVK_ANSI_KeypadMultiply: return @"*"; - case kVK_ANSI_KeypadPlus: return @"+"; - case kVK_ANSI_KeypadClear: return MASShortcutChar(kMASShortcutGlyphPadClear); - case kVK_ANSI_KeypadDivide: return @"/"; - case kVK_ANSI_KeypadEnter: return MASShortcutChar(kMASShortcutGlyphReturn); - case kVK_ANSI_KeypadMinus: return @"–"; - case kVK_ANSI_KeypadEquals: return @"="; - - // Hardcode - case 119: return MASShortcutChar(kMASShortcutGlyphSoutheastArrow); - case 115: return MASShortcutChar(kMASShortcutGlyphNorthwestArrow); - } - - // Everything else should be printable so look it up in the current keyboard - OSStatus error = noErr; - NSString *keystroke = nil; - TISInputSourceRef inputSource = TISCopyCurrentKeyboardLayoutInputSource(); - if (inputSource) { - CFDataRef layoutDataRef = TISGetInputSourceProperty(inputSource, kTISPropertyUnicodeKeyLayoutData); - if (layoutDataRef) { - UCKeyboardLayout *layoutData = (UCKeyboardLayout *)CFDataGetBytePtr(layoutDataRef); - UniCharCount length = 0; - UniChar chars[256] = { 0 }; - UInt32 deadKeyState = 0; - error = UCKeyTranslate(layoutData, self.keyCode, kUCKeyActionDisplay, 0, // No modifiers - LMGetKbdType(), kUCKeyTranslateNoDeadKeysMask, &deadKeyState, - sizeof(chars) / sizeof(UniChar), &length, chars); - keystroke = ((error == noErr) && length ? [NSString stringWithCharacters:chars length:length] : @""); - } - CFRelease(inputSource); - } - - // Validate keystroke - if (keystroke.length) { - static NSMutableCharacterSet *validChars = nil; - if (validChars == nil) { - validChars = [[NSMutableCharacterSet alloc] init]; - [validChars formUnionWithCharacterSet:[NSCharacterSet alphanumericCharacterSet]]; - [validChars formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]]; - [validChars formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]]; - } - for (NSUInteger i = 0, length = keystroke.length; i < length; i++) { - if (![validChars characterIsMember:[keystroke characterAtIndex:i]]) { - keystroke = @""; - break; - } - } - } - - // Finally, we've got a shortcut! - return keystroke.uppercaseString; -} - -- (NSString *)modifierFlagsString -{ - unichar chars[4]; - NSUInteger count = 0; - // These are in the same order as the menu manager shows them - if (self.modifierFlags & NSControlKeyMask) chars[count++] = kControlUnicode; - if (self.modifierFlags & NSAlternateKeyMask) chars[count++] = kOptionUnicode; - if (self.modifierFlags & NSShiftKeyMask) chars[count++] = kShiftUnicode; - if (self.modifierFlags & NSCommandKeyMask) chars[count++] = kCommandUnicode; - return (count ? [NSString stringWithCharacters:chars length:count] : @""); -} - -#pragma mark - Validation logic - -- (BOOL)shouldBypass -{ - NSString *codeString = self.keyCodeString; - return (self.modifierFlags == NSCommandKeyMask) && ([codeString isEqualToString:@"W"] || [codeString isEqualToString:@"Q"]); -} - -BOOL MASShortcutAllowsAnyHotkeyWithOptionModifier = NO; - -+ (void)setAllowsAnyHotkeyWithOptionModifier:(BOOL)allow -{ - MASShortcutAllowsAnyHotkeyWithOptionModifier = allow; -} - -+ (BOOL)allowsAnyHotkeyWithOptionModifier -{ - return MASShortcutAllowsAnyHotkeyWithOptionModifier; -} - -- (BOOL)isValid -{ - // Allow any function key with any combination of modifiers - BOOL includesFunctionKey = ((_keyCode == kVK_F1) || (_keyCode == kVK_F2) || (_keyCode == kVK_F3) || (_keyCode == kVK_F4) || - (_keyCode == kVK_F5) || (_keyCode == kVK_F6) || (_keyCode == kVK_F7) || (_keyCode == kVK_F8) || - (_keyCode == kVK_F9) || (_keyCode == kVK_F10) || (_keyCode == kVK_F11) || (_keyCode == kVK_F12) || - (_keyCode == kVK_F13) || (_keyCode == kVK_F14) || (_keyCode == kVK_F15) || (_keyCode == kVK_F16) || - (_keyCode == kVK_F17) || (_keyCode == kVK_F18) || (_keyCode == kVK_F19) || (_keyCode == kVK_F20)); - if (includesFunctionKey) return YES; - - // Do not allow any other key without modifiers - BOOL hasModifierFlags = (_modifierFlags > 0); - if (!hasModifierFlags) return NO; - - // Allow any hotkey containing Control or Command modifier - BOOL includesCommand = ((_modifierFlags & NSCommandKeyMask) > 0); - BOOL includesControl = ((_modifierFlags & NSControlKeyMask) > 0); - if (includesCommand || includesControl) return YES; - - // Allow Option key only in selected cases - BOOL includesOption = ((_modifierFlags & NSAlternateKeyMask) > 0); - if (includesOption) { - - // Always allow Option-Space and Option-Escape because they do not have any bind system commands - if ((_keyCode == kVK_Space) || (_keyCode == kVK_Escape)) return YES; - - // Allow Option modifier with any key even if it will break the system binding - if ([[self class] allowsAnyHotkeyWithOptionModifier]) return YES; - } - - // The hotkey does not have any modifiers or violates system bindings - return NO; -} - -- (BOOL)isKeyEquivalent:(NSString *)keyEquivalent flags:(NSUInteger)flags takenInMenu:(NSMenu *)menu error:(NSError **)outError -{ - for (NSMenuItem *menuItem in menu.itemArray) { - if (menuItem.hasSubmenu && [self isKeyEquivalent:keyEquivalent flags:flags takenInMenu:menuItem.submenu error:outError]) return YES; - - BOOL equalFlags = (MASShortcutClear(menuItem.keyEquivalentModifierMask) == flags); - BOOL equalHotkeyLowercase = [menuItem.keyEquivalent.lowercaseString isEqualToString:keyEquivalent]; - - // Check if the cases are different, we know ours is lower and that shift is included in our modifiers - // If theirs is capitol, we need to add shift to their modifiers - if (equalHotkeyLowercase && ![menuItem.keyEquivalent isEqualToString:keyEquivalent]) { - equalFlags = (MASShortcutClear(menuItem.keyEquivalentModifierMask | NSShiftKeyMask) == flags); - } - - if (equalFlags && equalHotkeyLowercase) { - if (outError) { - NSString *format = NSLocalizedString(@"This shortcut cannot be used because it is already used by the menu item ‘%@’.", - @"Message for alert when shortcut is already used"); - NSDictionary *info = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:format, menuItem.title] - forKey:NSLocalizedDescriptionKey]; - *outError = [NSError errorWithDomain:NSCocoaErrorDomain code:0 userInfo:info]; - } - return YES; - } - } - return NO; -} - -- (BOOL)isTakenError:(NSError **)outError -{ - CFArrayRef globalHotKeys; - if (CopySymbolicHotKeys(&globalHotKeys) == noErr) { - - // Enumerate all global hotkeys and check if any of them matches current shortcut - for (CFIndex i = 0, count = CFArrayGetCount(globalHotKeys); i < count; i++) { - CFDictionaryRef hotKeyInfo = CFArrayGetValueAtIndex(globalHotKeys, i); - CFNumberRef code = CFDictionaryGetValue(hotKeyInfo, kHISymbolicHotKeyCode); - CFNumberRef flags = CFDictionaryGetValue(hotKeyInfo, kHISymbolicHotKeyModifiers); - - if (([(__bridge NSNumber *)code unsignedIntegerValue] == self.keyCode) && - ([(__bridge NSNumber *)flags unsignedIntegerValue] == self.carbonFlags)) { - - if (outError) { - NSString *description = NSLocalizedString(@"This combination cannot be used because it is already used by a system-wide " - @"keyboard shortcut.\nIf you really want to use this key combination, most shortcuts " - @"can be changed in the Keyboard & Mouse panel in System Preferences.", - @"Message for alert when shortcut is already used by the system"); - NSDictionary *info = [NSDictionary dictionaryWithObject:description forKey:NSLocalizedDescriptionKey]; - *outError = [NSError errorWithDomain:NSCocoaErrorDomain code:0 userInfo:info]; - } - return YES; - } - } - CFRelease(globalHotKeys); - } - return [self isKeyEquivalent:self.keyCodeStringForKeyEquivalent flags:self.modifierFlags takenInMenu:[NSApp mainMenu] error:outError]; -} - -@end diff --git a/vendor/Pods/MASShortcut/MASShortcutView+UserDefaults.h b/vendor/Pods/MASShortcut/MASShortcutView+UserDefaults.h deleted file mode 100644 index 05d3c5b..0000000 --- a/vendor/Pods/MASShortcut/MASShortcutView+UserDefaults.h +++ /dev/null @@ -1,7 +0,0 @@ -#import "MASShortcutView.h" - -@interface MASShortcutView (UserDefaults) - -@property (nonatomic, copy) NSString *associatedUserDefaultsKey; - -@end diff --git a/vendor/Pods/MASShortcut/MASShortcutView+UserDefaults.m b/vendor/Pods/MASShortcut/MASShortcutView+UserDefaults.m deleted file mode 100644 index bbe1dd2..0000000 --- a/vendor/Pods/MASShortcut/MASShortcutView+UserDefaults.m +++ /dev/null @@ -1,130 +0,0 @@ -#import "MASShortcutView+UserDefaults.h" -#import "MASShortcut.h" -#import - -@interface MASShortcutDefaultsObserver : NSObject - -@property (nonatomic, readonly) NSString *userDefaultsKey; -@property (nonatomic, readonly, weak) MASShortcutView *shortcutView; - -- (id)initWithShortcutView:(MASShortcutView *)shortcutView userDefaultsKey:(NSString *)userDefaultsKey; - -@end - -#pragma mark - - -@implementation MASShortcutView (UserDefaults) - -void *MASAssociatedDefaultsObserver = &MASAssociatedDefaultsObserver; - -- (NSString *)associatedUserDefaultsKey -{ - MASShortcutDefaultsObserver *defaultsObserver = objc_getAssociatedObject(self, MASAssociatedDefaultsObserver); - return defaultsObserver.userDefaultsKey; -} - -- (void)setAssociatedUserDefaultsKey:(NSString *)associatedUserDefaultsKey -{ - // First, stop observing previous shortcut view - objc_setAssociatedObject(self, MASAssociatedDefaultsObserver, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - - if (associatedUserDefaultsKey.length == 0) return; - - // Next, start observing current shortcut view - MASShortcutDefaultsObserver *defaultsObserver = [[MASShortcutDefaultsObserver alloc] initWithShortcutView:self userDefaultsKey:associatedUserDefaultsKey]; - objc_setAssociatedObject(self, MASAssociatedDefaultsObserver, defaultsObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -@end - -#pragma mark - - -@implementation MASShortcutDefaultsObserver { - MASShortcut *_originalShortcut; - BOOL _internalPreferenceChange; - BOOL _internalShortcutChange; -} - -@synthesize userDefaultsKey = _userDefaultsKey; -@synthesize shortcutView = _shortcutView; - -#pragma mark - - -- (id)initWithShortcutView:(MASShortcutView *)shortcutView userDefaultsKey:(NSString *)userDefaultsKey -{ - self = [super init]; - if (self) { - _originalShortcut = shortcutView.shortcutValue; - _shortcutView = shortcutView; - _userDefaultsKey = userDefaultsKey.copy; - [self startObservingShortcutView]; - } - return self; -} - -- (void)dealloc -{ - // __weak _shortcutView is not yet deallocated because it refers MASShortcutDefaultsObserver - [self stopObservingShortcutView]; -} - -#pragma mark - - -void *kShortcutValueObserver = &kShortcutValueObserver; - -- (void)startObservingShortcutView -{ - // Read initial shortcut value from user preferences - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSData *data = [defaults dataForKey:_userDefaultsKey]; - _shortcutView.shortcutValue = [MASShortcut shortcutWithData:data]; - - // Observe user preferences to update shortcut value when it changed - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDefaultsDidChange:) name:NSUserDefaultsDidChangeNotification object:defaults]; - - // Observe the keyboard shortcut that user inputs by hand - [_shortcutView addObserver:self forKeyPath:@"shortcutValue" options:0 context:kShortcutValueObserver]; -} - -- (void)userDefaultsDidChange:(NSNotification *)note -{ - // Ignore notifications posted from -[self observeValueForKeyPath:] - if (_internalPreferenceChange) return; - - _internalShortcutChange = YES; - NSData *data = [note.object dataForKey:_userDefaultsKey]; - _shortcutView.shortcutValue = [MASShortcut shortcutWithData:data]; - _internalShortcutChange = NO; -} - -- (void)stopObservingShortcutView -{ - // Stop observing keyboard hotkeys entered by user in the shortcut view - [_shortcutView removeObserver:self forKeyPath:@"shortcutValue" context:kShortcutValueObserver]; - - // Stop observing user preferences - [[NSNotificationCenter defaultCenter] removeObserver:self name:NSUserDefaultsDidChangeNotification object:[NSUserDefaults standardUserDefaults]]; - - // Restore original hotkey in the shortcut view - _shortcutView.shortcutValue = _originalShortcut; -} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ - if (context == kShortcutValueObserver) { - if (_internalShortcutChange) return; - MASShortcut *shortcut = [object valueForKey:keyPath]; - _internalPreferenceChange = YES; - - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - [defaults setObject:(shortcut.data ?: [NSKeyedArchiver archivedDataWithRootObject:nil]) forKey:_userDefaultsKey]; - [defaults synchronize]; - - _internalPreferenceChange = NO; - } - else { - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; - } -} - -@end diff --git a/vendor/Pods/MASShortcut/MASShortcutView.h b/vendor/Pods/MASShortcut/MASShortcutView.h deleted file mode 100644 index 13163d4..0000000 --- a/vendor/Pods/MASShortcut/MASShortcutView.h +++ /dev/null @@ -1,20 +0,0 @@ -@class MASShortcut; - -typedef enum { - MASShortcutViewAppearanceDefault = 0, // Height = 19 px - MASShortcutViewAppearanceTexturedRect, // Height = 25 px - MASShortcutViewAppearanceRounded // Height = 43 px -} MASShortcutViewAppearance; - -@interface MASShortcutView : NSView - -@property (nonatomic, strong) MASShortcut *shortcutValue; -@property (nonatomic, getter = isRecording) BOOL recording; -@property (nonatomic, getter = isEnabled) BOOL enabled; -@property (nonatomic, copy) void (^shortcutValueChange)(MASShortcutView *sender); -@property (nonatomic) MASShortcutViewAppearance appearance; - -/// Returns custom class for drawing control. -+ (Class)shortcutCellClass; - -@end diff --git a/vendor/Pods/MASShortcut/README.md b/vendor/Pods/MASShortcut/README.md index 47032aa..c79dbee 100644 --- a/vendor/Pods/MASShortcut/README.md +++ b/vendor/Pods/MASShortcut/README.md @@ -1,32 +1,65 @@ +[![Build Status](https://travis-ci.org/shpakovski/MASShortcut.svg?branch=master)](https://travis-ci.org/shpakovski/MASShortcut) + # Intro -Some time ago Cocoa developers used a brilliant framework [ShortcutRecorder](http://wafflesoftware.net/shortcut/) for managing keyboard shortcuts in application preferences. However, it became incompatible with a new plugin architecture of Xcode 4. +Some time ago Cocoa developers used a brilliant framework [ShortcutRecorder](http://wafflesoftware.net/shortcut/) for managing keyboard shortcuts in application preferences. However, it became incompatible with the new plugin architecture of Xcode 4. + +The MASShortcut project introduces a modern API and user interface for recording, storing and using system-wide keyboard shortcuts. All code is compatible with recent Xcode & OS X versions and the sandboxed environment. + +# Installation + +You can use [CocoaPods](http://cocoapods.org/), adding the following line to your Podfile: + + pod 'MASShortcut' -The project MASShortcut introduces modern API and user interface for recording, storing and using global keyboard shortcuts. All code is compatible with Xcode 4.3, Mac OS X 10.7 and the sandboxed environment. +If you want to stick to the 1.x branch, you can use the version smart match operator: + + pod 'MASShortcut', '~> 1' # Usage I hope, it is really easy: ```objective-c -// Drop a custom view into XIB and set its class to MASShortcutView +#import + +// Drop a custom view into XIB, set its class to MASShortcutView +// and its height to 19. If you select another appearance style, +// look up the correct height values in MASShortcutView.h. @property (nonatomic, weak) IBOutlet MASShortcutView *shortcutView; - -// Think up a preference key to store a global shortcut between launches -NSString *const kPreferenceGlobalShortcut = @"GlobalShortcut"; -// Assign the preference key and the shortcut view will take care of persistence +// Pick a preference key to store the shortcut between launches +static NSString *const kPreferenceGlobalShortcut = @"GlobalShortcut"; + +// Associate the shortcut view with user defaults self.shortcutView.associatedUserDefaultsKey = kPreferenceGlobalShortcut; -// Execute your block of code automatically when user triggers a shortcut from preferences -[MASShortcut registerGlobalShortcutWithUserDefaultsKey:kPreferenceGlobalShortcut handler:^{ - // Let me know if you find a better or more convenient API. +// Associate the preference key with an action +[[MASShortcutBinder sharedBinder] + bindShortcutWithDefaultsKey:kPreferenceGlobalShortcut + toAction:^{ + // Let me know if you find a better or a more convenient API. }]; ``` -To set an example, I made a demo project: [MASShortcutDemo](https://github.com/shpakovski/MASShortcutDemo). Enjoy! +You can see a real usage example in the Demo target. Enjoy! + +# Shortcut Recorder Compatibility + +By default, MASShortcut uses a different User Defaults storage format incompatible with Shortcut Recorder. But it’s easily possible to change that, so that you can replace Shortcut Recorder with MASShortcut without having to migrate the shortcuts previously stored by your apps. There are two parts of the story: + +If you bind the recorder control (`MASShortcutView`) to User defaults, set the Value Transformer field in the Interface Builder to `MASDictionaryTransformer`. This makes sure the shortcuts are written in the Shortcut Recorder format. + +If you use `MASShortcutBinder` to automatically load shortcuts from User Defaults, set the `bindingOptions` accordingly: + +```objective-c +[[MASShortcutBinder sharedBinder] setBindingOptions:@{NSValueTransformerNameBindingOption:MASDictionaryTransformerName}]; +``` + +This makes sure that the shortcuts in the Shortcut Recorder format are loaded correctly. + +# Notifications -#Notifications By registering for KVO notifications from `NSUserDefaultsController`, you can get a callback whenever a user changes the shortcut, allowing you to perform any UI updates, or other code handling tasks. This is just as easy to implement: @@ -62,9 +95,16 @@ _observableKeyPath = [@"values." stringByAppendingString:kPreferenceGlobalShortc context:kGlobalShortcutContext]; ``` -# Non-ARC Version +# Using in Swift projects + + 1. Install as a Pod using the latest CocoaPods with Swift support. + 2. Create a bridging header file [using the instructions here](http://swiftalicio.us/2014/11/using-cocoapods-from-swift/) + 3. Your bridging header file should contain the following [two](https://github.com/shpakovski/MASShortcut/issues/36) imports: -If you like retain/release, please check out these forks: [heardrwt/MASShortcut](https://github.com/heardrwt/MASShortcut) and [chendo/MASShortcut](https://github.com/chendo/MASShortcut). However, the preferred way is to enable the `-fobjc-arc` in Xcode source options. +```objective-c +#import +#import +``` # Copyright diff --git a/vendor/Pods/Manifest.lock b/vendor/Pods/Manifest.lock index 4278b64..0d2e2bb 100644 --- a/vendor/Pods/Manifest.lock +++ b/vendor/Pods/Manifest.lock @@ -1,13 +1,33 @@ PODS: - - MASShortcut (1.2.3) - - SocketRocket (0.3.1-beta2) + - AFNetworking (2.5.0): + - AFNetworking/NSURLConnection (= 2.5.0) + - AFNetworking/NSURLSession (= 2.5.0) + - AFNetworking/Reachability (= 2.5.0) + - AFNetworking/Security (= 2.5.0) + - AFNetworking/Serialization (= 2.5.0) + - AFNetworking/UIKit (= 2.5.0) + - AFNetworking/NSURLConnection (2.5.0): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/NSURLSession (2.5.0): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (2.5.0) + - AFNetworking/Security (2.5.0) + - AFNetworking/Serialization (2.5.0) + - MASShortcut (2.1.1) + - SocketRocket (0.2.0) DEPENDENCIES: + - AFNetworking (~> 2.0) - MASShortcut - SocketRocket SPEC CHECKSUMS: - MASShortcut: 6abaedac53a0542f4856f35be4f1f970b652a51e - SocketRocket: 7ac946bcce46287a791dfff3c1f8daa692821dae + AFNetworking: 0f54cb5d16ce38c1b76948faffb8d5fb705021c7 + MASShortcut: eaf6fc60ae9742d21312b2463c4ac25bcdb27f24 + SocketRocket: 6c9cfd1592bea82262b4283dcda3a7de166af3b6 -COCOAPODS: 0.29.0 +COCOAPODS: 0.35.0 diff --git a/vendor/Pods/Pods-MASShortcut-Private.xcconfig b/vendor/Pods/Pods-MASShortcut-Private.xcconfig deleted file mode 100644 index d5d9d52..0000000 --- a/vendor/Pods/Pods-MASShortcut-Private.xcconfig +++ /dev/null @@ -1,5 +0,0 @@ -#include "Pods-MASShortcut.xcconfig" -GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1 -HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/MASShortcut" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/MASShortcut" "${PODS_ROOT}/Headers/SocketRocket" -OTHER_LDFLAGS = -ObjC ${PODS_MASSHORTCUT_OTHER_LDFLAGS} -PODS_ROOT = ${SRCROOT} \ No newline at end of file diff --git a/vendor/Pods/Pods-MASShortcut.xcconfig b/vendor/Pods/Pods-MASShortcut.xcconfig deleted file mode 100644 index 92a9d32..0000000 --- a/vendor/Pods/Pods-MASShortcut.xcconfig +++ /dev/null @@ -1 +0,0 @@ -PODS_MASSHORTCUT_OTHER_LDFLAGS = -framework Carbon \ No newline at end of file diff --git a/vendor/Pods/Pods-SocketRocket-Private.xcconfig b/vendor/Pods/Pods-SocketRocket-Private.xcconfig deleted file mode 100644 index 0aa0a1a..0000000 --- a/vendor/Pods/Pods-SocketRocket-Private.xcconfig +++ /dev/null @@ -1,5 +0,0 @@ -#include "Pods-SocketRocket.xcconfig" -GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1 -HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/SocketRocket" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/MASShortcut" "${PODS_ROOT}/Headers/SocketRocket" -OTHER_LDFLAGS = -ObjC ${PODS_SOCKETROCKET_OTHER_LDFLAGS} -PODS_ROOT = ${SRCROOT} \ No newline at end of file diff --git a/vendor/Pods/Pods-SocketRocket.xcconfig b/vendor/Pods/Pods-SocketRocket.xcconfig deleted file mode 100644 index 47a72d6..0000000 --- a/vendor/Pods/Pods-SocketRocket.xcconfig +++ /dev/null @@ -1 +0,0 @@ -PODS_SOCKETROCKET_OTHER_LDFLAGS = -licucore -framework CoreServices -framework Security \ No newline at end of file diff --git a/vendor/Pods/Pods-environment.h b/vendor/Pods/Pods-environment.h deleted file mode 100644 index c84414f..0000000 --- a/vendor/Pods/Pods-environment.h +++ /dev/null @@ -1,20 +0,0 @@ - -// To check if a library is compiled with CocoaPods you -// can use the `COCOAPODS` macro definition which is -// defined in the xcconfigs so it is available in -// headers also when they are imported in the client -// project. - - -// MASShortcut -#define COCOAPODS_POD_AVAILABLE_MASShortcut -#define COCOAPODS_VERSION_MAJOR_MASShortcut 1 -#define COCOAPODS_VERSION_MINOR_MASShortcut 2 -#define COCOAPODS_VERSION_PATCH_MASShortcut 3 - -// SocketRocket -#define COCOAPODS_POD_AVAILABLE_SocketRocket -#define COCOAPODS_VERSION_MAJOR_SocketRocket 0 -#define COCOAPODS_VERSION_MINOR_SocketRocket 3 -#define COCOAPODS_VERSION_PATCH_SocketRocket 1 - diff --git a/vendor/Pods/Pods.bridgesupport b/vendor/Pods/Pods.bridgesupport deleted file mode 100644 index 6719ba9..0000000 --- a/vendor/Pods/Pods.bridgesupport +++ /dev/null @@ -1,331 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vendor/Pods/Pods.xcconfig b/vendor/Pods/Pods.xcconfig deleted file mode 100644 index b08858b..0000000 --- a/vendor/Pods/Pods.xcconfig +++ /dev/null @@ -1,5 +0,0 @@ -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/MASShortcut" "${PODS_ROOT}/Headers/SocketRocket" -OTHER_CFLAGS = $(inherited) "-isystem${PODS_ROOT}/Headers" "-isystem${PODS_ROOT}/Headers/MASShortcut" "-isystem${PODS_ROOT}/Headers/SocketRocket" -OTHER_LDFLAGS = -ObjC -licucore -framework Carbon -framework CoreServices -framework Security -PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/vendor/Pods/Pods.xcodeproj/project.pbxproj b/vendor/Pods/Pods.xcodeproj/project.pbxproj index aa244f4..2fb1828 100644 --- a/vendor/Pods/Pods.xcodeproj/project.pbxproj +++ b/vendor/Pods/Pods.xcodeproj/project.pbxproj @@ -10,51 +10,57 @@ 46 objects - 02B0BD60483D46D6AFE364E5 + 0089DD40658511F2C68D5441 - includeInIndex - 1 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - Pods-MASShortcut-prefix.pch - sourceTree - <group> - - 03C462AC59934C9F875A7D79 - - children + buildConfigurationList + 8B531D307B6C41CC01E5F43E + buildPhases - BFFB8C08134544689BF47835 - 9ED6AC70029843ECBD5272EA - 09E2168063FA4DDFAB2BBE87 - 7E7A27A0C7EE43E2B0CA3DD6 - 1B00A27BE03B47BD868AB31F - 46F8C29D64504A54BADC1928 + 3630CD0CB861703BC5966AAF + 7996D1F4B68E4F238FD457C7 + F57E5F8329878AD44B101BA1 + buildRules + + dependencies + isa - PBXGroup + PBXNativeTarget name - Pods - sourceTree - <group> + Pods-MASShortcut + productName + Pods-MASShortcut + productReference + 838F6142BF37BF556C11F454 + productType + com.apple.product-type.library.static - 05F055A36872408A8F3D3710 + 049308269D242EBC48273514 - explicitFileType - archive.ar - includeInIndex - 0 + fileRef + 90280D34A96E8520686586AB isa - PBXFileReference - path - libPods-SocketRocket.a - sourceTree - BUILT_PRODUCTS_DIR + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + 069FCCCE8D25B9D38774A2B1 + + buildActionMask + 2147483647 + files + + A443DE3DA6A946ED34CA0D9B + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 - 067B5AFA614548C3A4B8600D + 07ABE605310690E4F30996E2 includeInIndex 1 @@ -63,48 +69,49 @@ lastKnownFileType sourcecode.c.h name - base64.h + AFHTTPRequestOperationManager.h path - SocketRocket/base64.h + AFNetworking/AFHTTPRequestOperationManager.h sourceTree <group> - 082BCE6468734DC49CA21092 + 08C4D0059A603C5CC722190A - children + buildActionMask + 2147483647 + files - D40E833870214E3C9A8B4476 - CDA2050D0157400E9C058312 - 05F055A36872408A8F3D3710 + C675DA9C092A11E98AB975B9 + 1F5FA4BA4CE4FAD1A77BBF6C + 99CB3DF62DB1AA68187AE308 isa - PBXGroup - name - Products - sourceTree - <group> + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 - 09E2168063FA4DDFAB2BBE87 + 090A34383DCC113ADE2BFDBC - includeInIndex - 1 + fileRef + CE3250763B9346E46A764214 isa - PBXFileReference - lastKnownFileType - text.plist.xml - path - Pods-acknowledgements.plist - sourceTree - <group> + PBXBuildFile + + 0C2EF97ACEE76A071487CF14 + + fileRef + 3D8759D02073E31EBAD26857 + isa + PBXBuildFile - 0C86D40D1EAB4568AC2CD8FF + 0CA0C4D365D576E0C5218A66 fileRef - 173FCDC593354E51A65D6D53 + 225288A18A1F9D90309B5C09 isa PBXBuildFile - 0DA83F041F7E403F82938ED3 + 0EE1F4CF5CF11894F3E935C5 includeInIndex 1 @@ -112,41 +119,29 @@ PBXFileReference lastKnownFileType sourcecode.c.h + name + MASHotKey.h path - Pods-SocketRocket-prefix.pch + Framework/MASHotKey.h sourceTree <group> - 0E9FCAE734234F488A4A8DAB - - buildConfigurations - - 2CF14EF12ABD4FE3BEA55C93 - F4A4D26907934A05A7BC6E95 - - defaultConfigurationIsVisible - 0 - defaultConfigurationName - Release - isa - XCConfigurationList - - 1117BEB7EE124497A2F00918 + 0F152C6337CF3415E7D19F67 fileRef - 067B5AFA614548C3A4B8600D + 455E4DD4EC90D46BEB55CBE7 isa PBXBuildFile - 1165A5060BA94500B9EAD786 + 0F40D51E432D7E226B2DDF2F buildConfigurationList - 1F3504AA569844E896AF74C3 + 34CB2EF93D493DFEF3B00C10 buildPhases - 9AEA02CBFF10497CAD28E3B8 - 7B00A0E255914BEABC074544 - A847C3FC21BF4C128E47CE1D + 9B366904CDE9B4BCE13830C4 + FD40EC174BC339958657D7E7 + EFA41ED7CCC1BA6CCBB030E4 buildRules @@ -155,127 +150,210 @@ isa PBXNativeTarget name - Pods-MASShortcut + Pods-AFNetworking productName - Pods-MASShortcut + Pods-AFNetworking productReference - CDA2050D0157400E9C058312 + EF22A89320848BC05463F4A3 productType com.apple.product-type.library.static - 11A662FC31584CCCAA7BE2E1 + 1129C9B62B72AE6828F4EB1F + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + COPY_PHASE_STRIP + YES + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_DYNAMIC_NO_PIC + NO + GCC_OPTIMIZATION_LEVEL + 0 + GCC_PREPROCESSOR_DEFINITIONS + + DEBUG=1 + $(inherited) + + GCC_SYMBOLS_PRIVATE_EXTERN + NO + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + MACOSX_DEPLOYMENT_TARGET + 10.8 + ONLY_ACTIVE_ARCH + YES + STRIP_INSTALLED_PRODUCT + NO + + isa + XCBuildConfiguration + name + Debug + + 133057AF82EACBC481FE9983 + + children + + 976DEF42578884FCD507CA95 + EF22A89320848BC05463F4A3 + 838F6142BF37BF556C11F454 + F1B2D2DC7E031CF249B25BC1 + + isa + PBXGroup + name + Products + sourceTree + <group> + + 141AA15F5753B38BF666ECF7 + + fileRef + D23B559BC654D3B27DAC9DC0 + isa + PBXBuildFile + + 1A3444D2B78E863B4B99FE5C includeInIndex 1 isa PBXFileReference lastKnownFileType - text.xcconfig + sourcecode.c.h path - Pods-MASShortcut.xcconfig + Pods-MASShortcut-prefix.pch sourceTree <group> - 11A98F2EB6B3481DA38DEF2A + 1CB7418B8FA2AEB1A7ACAB3D includeInIndex 1 isa PBXFileReference lastKnownFileType - sourcecode.c.objc + text.xcconfig path - MASShortcut.m + Pods-AFNetworking-Private.xcconfig sourceTree <group> - 12F3191829B04C05940486EF - - buildConfigurations - - EF1F15C1B8104423B741509F - A76340211D9B46B4BCE3C2E5 - - defaultConfigurationIsVisible - 0 - defaultConfigurationName - Release - isa - XCConfigurationList - - 1470DC568B4849BB8C570478 + 1DA5A047182D9CA95D4B6A1F - children - - 46DF5D8B2F0B440C8880417A - 589D5C4960814756994567B9 - AA94D76D2B81455986D0E8BF - 9A029CBACA5E411B9CEA1715 - + includeInIndex + 1 isa - PBXGroup - name - OS X + PBXFileReference + lastKnownFileType + text + path + Pods-acknowledgements.markdown sourceTree <group> - 150FBA295FBB4012B799B5AC + 1F2687545C131592B068C24B - containerPortal - 2EBF5D4433BF42D1A6D39878 - isa - PBXContainerItemProxy - proxyType + includeInIndex 1 - remoteGlobalIDString - 8FEED127C4CD4F8DA75E972C - remoteInfo - Pods-SocketRocket - - 15642AD9595B4EDDAC09D7F6 - - children - - 7926A797657942059A0B8372 - 6A2570E0643D4268A8FB0CAD - isa - PBXGroup + PBXFileReference + lastKnownFileType + sourcecode.c.h name - Pods + SRWebSocket.h + path + SocketRocket/SRWebSocket.h sourceTree <group> - 173FCDC593354E51A65D6D53 + 1F498CE74B75328E2F3AC128 includeInIndex 1 isa PBXFileReference lastKnownFileType - sourcecode.c.h + text.xcconfig path - MASShortcut+Monitoring.h + Pods.debug.xcconfig + sourceTree + <group> + + 1F5FA4BA4CE4FAD1A77BBF6C + + fileRef + 6521592AB534D100EA6630C0 + isa + PBXBuildFile + + 1FDC10D1BB0BACAF523B9DF8 + + children + + 9A70740C1D0CBA9114202261 + + isa + PBXGroup + name + Targets Support Files sourceTree <group> - 18B20D19FDE54DA0B9CDF522 + 1FEA81A48CEFC5D40B38021A children - 73E6F0BD07DE451AAB74A349 - 2B18B7DD0B314A48AEC299DF - 8C76A65BCCEB4A028E596156 - 0DA83F041F7E403F82938ED3 + 2CE53CCF080574252CE2DAD6 + 1CB7418B8FA2AEB1A7ACAB3D + 21D8DCAB26735485893B5155 + CEF2788FC4AB4868B1CD07B9 isa PBXGroup name Support Files + path + ../Target Support Files/Pods-AFNetworking sourceTree - SOURCE_ROOT + <group> - 1B00A27BE03B47BD868AB31F + 2018C4EEA6BD9268C94FDE31 includeInIndex 1 @@ -283,24 +361,753 @@ PBXFileReference lastKnownFileType sourcecode.c.h - path - Pods-environment.h + name + MASShortcutView.h + path + Framework/MASShortcutView.h + sourceTree + <group> + + 210B28B1E63DD33AB7571E94 + + baseConfigurationReference + 30F86373A49B0580F4DE1A13 + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + ARCHS + $(ARCHS_STANDARD_64_BIT) + COMBINE_HIDPI_IMAGES + YES + COPY_PHASE_STRIP + YES + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DSTROOT + /tmp/xcodeproj.dst + GCC_ENABLE_OBJC_EXCEPTIONS + YES + GCC_PRECOMPILE_PREFIX_HEADER + YES + GCC_VERSION + com.apple.compilers.llvm.clang.1_0 + INSTALL_PATH + $(BUILT_PRODUCTS_DIR) + MACOSX_DEPLOYMENT_TARGET + 10.8 + OTHER_CFLAGS + + -DNS_BLOCK_ASSERTIONS=1 + $(inherited) + + OTHER_CPLUSPLUSFLAGS + + -DNS_BLOCK_ASSERTIONS=1 + $(inherited) + + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PRODUCT_NAME + $(TARGET_NAME) + SDKROOT + macosx + SKIP_INSTALL + YES + + isa + XCBuildConfiguration + name + Release + + 21D8DCAB26735485893B5155 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + Pods-AFNetworking-dummy.m + sourceTree + <group> + + 225288A18A1F9D90309B5C09 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + base64.h + path + SocketRocket/base64.h + sourceTree + <group> + + 26892C4EE4E57D5400F90871 + + fileRef + CAC4F4C4B47AA8189CC37108 + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + 279FC7B1A626599A39AC9F3F + + fileRef + 5D0C46008E8986B0D6FE7B3E + isa + PBXBuildFile + + 2CE53CCF080574252CE2DAD6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-AFNetworking.xcconfig + sourceTree + <group> + + 2D115316728D1BD16D98EEEF + + fileRef + 8AB5EB9A4B1ED7C4BCF910EF + isa + PBXBuildFile + + 2E96CEBE0F63120D7CD6184A + + fileRef + 5D866178A310F60C0B18847E + isa + PBXBuildFile + + 2ED67259152D93AF9A2C09E4 + + fileRef + B70C8FA4CF04CD8A424248EF + isa + PBXBuildFile + + 30F86373A49B0580F4DE1A13 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods.release.xcconfig + sourceTree + <group> + + 32220FC4502FF715AB7BE25A + + fileRef + 8731277ACC741CFC8E3F961E + isa + PBXBuildFile + + 32C73158F90975601E0B2629 + + fileRef + 96F6E29C6212687390F7AD76 + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + 32FC02166DFE48FB3879CF49 + + isa + PBXTargetDependency + name + Pods-SocketRocket + target + 3C3CC8B320510DD261C2B145 + targetProxy + EB2DE1111901FEE19088EBE1 + + 33F1C21AE2C3532A2CE8B177 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFNetworkReachabilityManager.m + path + AFNetworking/AFNetworkReachabilityManager.m + sourceTree + <group> + + 34CB2EF93D493DFEF3B00C10 + + buildConfigurations + + CD82EC24C311F1CA4472DAD1 + EDC6E4A24CBECABCD5E68915 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 350A2E85F1B3F45E4FF28A5E + + fileRef + 6410E53E5DAD9D205D30B59C + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + 356F577B89948852E5ACA42C + + fileRef + 3B3E43346A66F782AADF36F7 + isa + PBXBuildFile + + 35A5DF67263BED3DEDFC735F + + fileRef + 07ABE605310690E4F30996E2 + isa + PBXBuildFile + + 3630CD0CB861703BC5966AAF + + buildActionMask + 2147483647 + files + + 26892C4EE4E57D5400F90871 + 32C73158F90975601E0B2629 + 049308269D242EBC48273514 + B46ADF10CDEA193639DCF637 + 368BC8A770202143937C49A3 + 60C93CB3ADDD453B584A700E + BD7A9D17C866685887EF5955 + 6C76055812FB02FA492B5FB2 + 0C2EF97ACEE76A071487CF14 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 368BC8A770202143937C49A3 + + fileRef + EBBE9626ED9FE968AD19B788 + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + 37C72163976E1E194A280CAB + + children + + 558DAA0E40341831DE5F1F51 + 6294203A87829A690C4EBD59 + 3D8759D02073E31EBAD26857 + 1A3444D2B78E863B4B99FE5C + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/Pods-MASShortcut + sourceTree + <group> + + 3AFE0AE8545CA00791858A02 + + fileRef + 33F1C21AE2C3532A2CE8B177 + isa + PBXBuildFile + + 3B3E43346A66F782AADF36F7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFSecurityPolicy.h + path + AFNetworking/AFSecurityPolicy.h + sourceTree + <group> + + 3B7B456DBC42C08FB825B327 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFHTTPRequestOperation.h + path + AFNetworking/AFHTTPRequestOperation.h + sourceTree + <group> + + 3C3CC8B320510DD261C2B145 + + buildConfigurationList + B1A2C145D1AE6906AB785AC3 + buildPhases + + CFDD3892BC0A27350F1F4BD4 + 08C4D0059A603C5CC722190A + B2EC8AE43BE1D1D2661E0D13 + + buildRules + + dependencies + + isa + PBXNativeTarget + name + Pods-SocketRocket + productName + Pods-SocketRocket + productReference + F1B2D2DC7E031CF249B25BC1 + productType + com.apple.product-type.library.static + + 3C9EAEA1B70A64643C08CEF2 + + children + + 6859FD10D8DCB55C0E834977 + 33F1C21AE2C3532A2CE8B177 + + isa + PBXGroup + name + Reachability + sourceTree + <group> + + 3CB980EF73542D6D4B2A0371 + + children + + B70C8FA4CF04CD8A424248EF + A87AB2F4C80345F28E6968A7 + 1F2687545C131592B068C24B + 6410E53E5DAD9D205D30B59C + 8A5664D49F1243587E09666A + 225288A18A1F9D90309B5C09 + 5C076965D72887436429E04A + + isa + PBXGroup + name + SocketRocket + path + SocketRocket + sourceTree + <group> + + 3D8759D02073E31EBAD26857 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + Pods-MASShortcut-dummy.m + sourceTree + <group> + + 3DCD509F2E242A7087CBBF9D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-SocketRocket-Private.xcconfig + sourceTree + <group> + + 3E6D8408B0648E2A2B779F96 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFNetworking.h + path + AFNetworking/AFNetworking.h + sourceTree + <group> + + 41CD9C6F6E79D12267678F25 + + children + + CE3250763B9346E46A764214 + 859951AE86BEE3F952400F3E + AA717EFA3A7D87E92C41DFBB + 6521592AB534D100EA6630C0 + F42872FD6DF4CE8BE89C4AC6 + 7CC6A62356F712860A83645A + + isa + PBXGroup + name + OS X + sourceTree + <group> + + 43EA72092035037EA38B9DC9 + + baseConfigurationReference + 3DCD509F2E242A7087CBBF9D + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + ARCHS + $(ARCHS_STANDARD_64_BIT) + COMBINE_HIDPI_IMAGES + YES + COPY_PHASE_STRIP + NO + DSTROOT + /tmp/xcodeproj.dst + GCC_DYNAMIC_NO_PIC + NO + GCC_ENABLE_OBJC_EXCEPTIONS + YES + GCC_OPTIMIZATION_LEVEL + 0 + GCC_PRECOMPILE_PREFIX_HEADER + YES + GCC_PREFIX_HEADER + Target Support Files/Pods-SocketRocket/Pods-SocketRocket-prefix.pch + GCC_PREPROCESSOR_DEFINITIONS + + DEBUG=1 + $(inherited) + + GCC_SYMBOLS_PRIVATE_EXTERN + NO + GCC_VERSION + com.apple.compilers.llvm.clang.1_0 + INSTALL_PATH + $(BUILT_PRODUCTS_DIR) + MACOSX_DEPLOYMENT_TARGET + 10.8 + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PRODUCT_NAME + $(TARGET_NAME) + SDKROOT + macosx + SKIP_INSTALL + YES + + isa + XCBuildConfiguration + name + Debug + + 446F81E58F55BC1155C74F14 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcutBinder.h + path + Framework/MASShortcutBinder.h + sourceTree + <group> + + 44DFE0F7E10683CA198906F6 + + buildConfigurationList + 5C6BE5DDC930A8BFBD51100E + buildPhases + + 069FCCCE8D25B9D38774A2B1 + 755E466ED8E1C8BF0D5D2687 + + buildRules + + dependencies + + E75E59D1196D669270B7798E + 67F238A9D9E965FDE9AAADD5 + 32FC02166DFE48FB3879CF49 + + isa + PBXNativeTarget + name + Pods + productName + Pods + productReference + 976DEF42578884FCD507CA95 + productType + com.apple.product-type.library.static + + 455E4DD4EC90D46BEB55CBE7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFSecurityPolicy.m + path + AFNetworking/AFSecurityPolicy.m + sourceTree + <group> + + 45B1AC4BA1FB1853E12E0555 + + fileRef + 8A5664D49F1243587E09666A + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + 45CD4D3C883901D270C6FF43 + + attributes + + LastUpgradeCheck + 0510 + + buildConfigurationList + 51CD82CB4C27E883501FCBAE + compatibilityVersion + Xcode 3.2 + developmentRegion + English + hasScannedForEncodings + 0 + isa + PBXProject + knownRegions + + en + + mainGroup + AEF743F9568F5F83368C49DC + productRefGroup + 133057AF82EACBC481FE9983 + projectDirPath + + projectReferences + + projectRoot + + targets + + 44DFE0F7E10683CA198906F6 + 0F40D51E432D7E226B2DDF2F + 0089DD40658511F2C68D5441 + 3C3CC8B320510DD261C2B145 + + + 4F59C346221EE132566D9B0D + + fileRef + 8350BA24D3852537D82617FC + isa + PBXBuildFile + + 4FE14DB0B4E78C22019E255A + + fileRef + 446F81E58F55BC1155C74F14 + isa + PBXBuildFile + + 4FF3C954F7AADC5A58EC8DEB + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + Pods-SocketRocket-prefix.pch + sourceTree + <group> + + 51CD82CB4C27E883501FCBAE + + buildConfigurations + + 1129C9B62B72AE6828F4EB1F + 77B4E53EEA0C30BB7894FA06 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 52F9DD000F2884866FC319C6 + + fileRef + 95315624722C94232CD00EFE + isa + PBXBuildFile + + 558DAA0E40341831DE5F1F51 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-MASShortcut.xcconfig + sourceTree + <group> + + 56C1D08DB4D6B945B40754A0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + Pods-dummy.m sourceTree <group> - 1B4DFC10216F465FBE1CF3EF + 58EEF5780FEB7F278CC894D0 fileRef - 50CA7B8E6E5C4602A2AEC1D9 + 73FC8B0BE2E829A7DFA1D3AF isa PBXBuildFile - 1F3504AA569844E896AF74C3 + 598618FF853C755C9483322D + + children + + 3B7B456DBC42C08FB825B327 + F5CBB13A080CD6B66398D31B + 07ABE605310690E4F30996E2 + 5D0C46008E8986B0D6FE7B3E + D23B559BC654D3B27DAC9DC0 + B47447B5B1000FAD7FCBAA65 + + isa + PBXGroup + name + NSURLConnection + sourceTree + <group> + + 5B61F8B08AB31EBD8E169B1A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-resources.sh + sourceTree + <group> + + 5C076965D72887436429E04A + + children + + B4398985227AEF90E5A36DE0 + 3DCD509F2E242A7087CBBF9D + 95315624722C94232CD00EFE + 4FF3C954F7AADC5A58EC8DEB + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/Pods-SocketRocket + sourceTree + <group> + + 5C6BE5DDC930A8BFBD51100E buildConfigurations - 7FF31F505E114C1483DED84B - 91F37B6C62384F9DA35EA92E + CFFD034D48D8E40859B1760A + 210B28B1E63DD33AB7571E94 defaultConfigurationIsVisible 0 @@ -309,22 +1116,14 @@ isa XCConfigurationList - 2649764896F84E9FB0DA5999 + 5C98A90DC872F708AD6211DD - buildActionMask - 2147483647 - files - - 66F0742E74774F7B8380F66B - 1B4DFC10216F465FBE1CF3EF - 1117BEB7EE124497A2F00918 - + fileRef + AA717EFA3A7D87E92C41DFBB isa - PBXHeadersBuildPhase - runOnlyForDeploymentPostprocessing - 0 + PBXBuildFile - 2A2A82B18D6D402E912E6BB3 + 5D0C46008E8986B0D6FE7B3E includeInIndex 1 @@ -332,226 +1131,240 @@ PBXFileReference lastKnownFileType sourcecode.c.objc + name + AFHTTPRequestOperationManager.m path - MASShortcutView+UserDefaults.m + AFNetworking/AFHTTPRequestOperationManager.m sourceTree <group> - 2B18B7DD0B314A48AEC299DF + 5D866178A310F60C0B18847E includeInIndex 1 isa PBXFileReference lastKnownFileType - text.xcconfig + sourcecode.c.h + name + MASKeyCodes.h path - Pods-SocketRocket-Private.xcconfig + Framework/MASKeyCodes.h sourceTree <group> - 2CF14EF12ABD4FE3BEA55C93 + 60C93CB3ADDD453B584A700E - baseConfigurationReference - 2B18B7DD0B314A48AEC299DF - buildSettings + fileRef + C557E09D55875091522BBD26 + isa + PBXBuildFile + settings - ALWAYS_SEARCH_USER_PATHS - NO - ARCHS - $(ARCHS_STANDARD_64_BIT) - COMBINE_HIDPI_IMAGES - YES - COPY_PHASE_STRIP - NO - DSTROOT - /tmp/xcodeproj.dst - GCC_C_LANGUAGE_STANDARD - gnu99 - GCC_DYNAMIC_NO_PIC - NO - GCC_ENABLE_OBJC_EXCEPTIONS - YES - GCC_OPTIMIZATION_LEVEL - 0 - GCC_PRECOMPILE_PREFIX_HEADER - YES - GCC_PREFIX_HEADER - Pods-SocketRocket-prefix.pch - GCC_PREPROCESSOR_DEFINITIONS - - DEBUG=1 - $(inherited) - - GCC_SYMBOLS_PRIVATE_EXTERN - NO - GCC_VERSION - com.apple.compilers.llvm.clang.1_0 - INSTALL_PATH - $(BUILT_PRODUCTS_DIR) - MACOSX_DEPLOYMENT_TARGET - 10.8 - OTHER_LDFLAGS - - PRODUCT_NAME - $(TARGET_NAME) - SDKROOT - macosx - SKIP_INSTALL - YES + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + 6294203A87829A690C4EBD59 + + includeInIndex + 1 isa - XCBuildConfiguration + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-MASShortcut-Private.xcconfig + sourceTree + <group> + + 63C57121D27447305EA32A1D + + fileRef + 9334DA37930E74A085F9E7C4 + isa + PBXBuildFile + + 63CF08C574AD4F3B83D13E3E + + fileRef + 3E6D8408B0648E2A2B779F96 + isa + PBXBuildFile + + 63EA81A331BB2DD47FAE2FFE + + fileRef + 21D8DCAB26735485893B5155 + isa + PBXBuildFile + + 6410E53E5DAD9D205D30B59C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc name - Debug + SRWebSocket.m + path + SocketRocket/SRWebSocket.m + sourceTree + <group> - 2EBF5D4433BF42D1A6D39878 + 6521592AB534D100EA6630C0 - attributes - - LastUpgradeCheck - 0500 - - buildConfigurationList - B29CCF39CA94499F92639377 - compatibilityVersion - Xcode 3.2 - developmentRegion - English - hasScannedForEncodings - 0 isa - PBXProject - knownRegions - - en - - mainGroup - C23B469BE8E54872A422417F - productRefGroup - 082BCE6468734DC49CA21092 - projectDirPath - - projectReferences - - projectRoot - - targets - - BF91D2B3B0614445AD297611 - 1165A5060BA94500B9EAD786 - 8FEED127C4CD4F8DA75E972C - + PBXFileReference + lastKnownFileType + wrapper.framework + name + CoreServices.framework + path + Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreServices.framework + sourceTree + DEVELOPER_DIR - 40BA25B286754649884B1995 + 66C8F8B682EE24852858B273 - buildSettings - - ALWAYS_SEARCH_USER_PATHS - NO - CLANG_CXX_LANGUAGE_STANDARD - gnu++0x - CLANG_CXX_LIBRARY - libc++ - CLANG_ENABLE_MODULES - YES - CLANG_ENABLE_OBJC_ARC - NO - CLANG_WARN_BOOL_CONVERSION - YES - CLANG_WARN_CONSTANT_CONVERSION - YES - CLANG_WARN_DIRECT_OBJC_ISA_USAGE - YES_ERROR - CLANG_WARN_EMPTY_BODY - YES - CLANG_WARN_ENUM_CONVERSION - YES - CLANG_WARN_INT_CONVERSION - YES - CLANG_WARN_OBJC_ROOT_CLASS - YES_ERROR - COPY_PHASE_STRIP - YES - GCC_C_LANGUAGE_STANDARD - gnu99 - GCC_DYNAMIC_NO_PIC - NO - GCC_OPTIMIZATION_LEVEL - 0 - GCC_PREPROCESSOR_DEFINITIONS - - DEBUG=1 - $(inherited) - - GCC_SYMBOLS_PRIVATE_EXTERN - NO - GCC_WARN_64_TO_32_BIT_CONVERSION - YES - GCC_WARN_ABOUT_RETURN_TYPE - YES_ERROR - GCC_WARN_UNDECLARED_SELECTOR - YES - GCC_WARN_UNINITIALIZED_AUTOS - YES - GCC_WARN_UNUSED_FUNCTION - YES - GCC_WARN_UNUSED_VARIABLE - YES - MACOSX_DEPLOYMENT_TARGET - 10.8 - ONLY_ACTIVE_ARCH - YES - STRIP_INSTALLED_PRODUCT - NO - + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLRequestSerialization.h + path + AFNetworking/AFURLRequestSerialization.h + sourceTree + <group> + + 6754C143FA3CA66C8971069A + + containerPortal + 45CD4D3C883901D270C6FF43 isa - XCBuildConfiguration + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 0089DD40658511F2C68D5441 + remoteInfo + Pods-MASShortcut + + 675D41B14F38679544A34919 + + children + + 8AB5EB9A4B1ED7C4BCF910EF + C5A5A2F63905CCD4D939A76E + 9334DA37930E74A085F9E7C4 + F56DD32A1209CF7A2AA284E8 + + isa + PBXGroup name - Debug + NSURLSession + sourceTree + <group> + + 67F238A9D9E965FDE9AAADD5 + + isa + PBXTargetDependency + name + Pods-MASShortcut + target + 0089DD40658511F2C68D5441 + targetProxy + 6754C143FA3CA66C8971069A - 41DD136B0EDB4EF7993F7634 + 6859FD10D8DCB55C0E834977 includeInIndex 1 isa PBXFileReference lastKnownFileType - sourcecode.c.objc + sourcecode.c.h name - NSData+SRB64Additions.m + AFNetworkReachabilityManager.h path - SocketRocket/NSData+SRB64Additions.m + AFNetworking/AFNetworkReachabilityManager.h sourceTree <group> - 46DF5D8B2F0B440C8880417A + 68A93585CE67991AEDD920BF + fileRef + F56DD32A1209CF7A2AA284E8 isa - PBXFileReference - lastKnownFileType - wrapper.framework - name - Carbon.framework - path - Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Carbon.framework - sourceTree - DEVELOPER_DIR + PBXBuildFile + + 6C76055812FB02FA492B5FB2 + + fileRef + FEB5DDEA35BB8EB7C89389B2 + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + 6DC28C2A7A1762CE0069B404 + + fileRef + 6521592AB534D100EA6630C0 + isa + PBXBuildFile + + 71ED18CA46AE8D1DE7FEDD04 + + containerPortal + 45CD4D3C883901D270C6FF43 + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 0F40D51E432D7E226B2DDF2F + remoteInfo + Pods-AFNetworking - 46F8C29D64504A54BADC1928 + 73FC8B0BE2E829A7DFA1D3AF includeInIndex 1 isa PBXFileReference lastKnownFileType - text.script.sh + sourcecode.c.h + name + MASShortcut.h path - Pods-resources.sh + Framework/MASShortcut.h sourceTree <group> - 48927BABFD3749D0BACCC9CB + 755E466ED8E1C8BF0D5D2687 + + buildActionMask + 2147483647 + files + + D4D2CA2F0DEC94BA2E27C7A6 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 77B4E53EEA0C30BB7894FA06 buildSettings @@ -564,13 +1377,13 @@ CLANG_ENABLE_MODULES YES CLANG_ENABLE_OBJC_ARC - NO + YES CLANG_WARN_BOOL_CONVERSION YES CLANG_WARN_CONSTANT_CONVERSION YES CLANG_WARN_DIRECT_OBJC_ISA_USAGE - YES_ERROR + YES CLANG_WARN_EMPTY_BODY YES CLANG_WARN_ENUM_CONVERSION @@ -578,17 +1391,21 @@ CLANG_WARN_INT_CONVERSION YES CLANG_WARN_OBJC_ROOT_CLASS - YES_ERROR + YES COPY_PHASE_STRIP NO ENABLE_NS_ASSERTIONS NO GCC_C_LANGUAGE_STANDARD gnu99 + GCC_PREPROCESSOR_DEFINITIONS + + RELEASE=1 + GCC_WARN_64_TO_32_BIT_CONVERSION YES GCC_WARN_ABOUT_RETURN_TYPE - YES_ERROR + YES GCC_WARN_UNDECLARED_SELECTOR YES GCC_WARN_UNINITIALIZED_AUTOS @@ -609,7 +1426,7 @@ name Release - 50CA7B8E6E5C4602A2AEC1D9 + 77F83B2ADD0808355BFC7C68 includeInIndex 1 @@ -618,67 +1435,198 @@ lastKnownFileType sourcecode.c.h name - SRWebSocket.h + MASShortcutValidator.h path - SocketRocket/SRWebSocket.h + Framework/MASShortcutValidator.h sourceTree <group> - 57D3A927F6A04192BBCC03E0 + 789554EE8C9ED7F775A7B90F + + fileRef + F42872FD6DF4CE8BE89C4AC6 + isa + PBXBuildFile + + 7996D1F4B68E4F238FD457C7 buildActionMask 2147483647 files - C088DAB27C1C4363A84B987B - FF4286A8004C427690982A9F - C6CE6A2E4FE1450A9E03AFF0 + 090A34383DCC113ADE2BFDBC + F8D644A2C51EC2AB7D5BAAB0 + 91FFBFBBECDFFA585DCAF00D isa PBXFrameworksBuildPhase runOnlyForDeploymentPostprocessing 0 - 589D5C4960814756994567B9 + 7A8BD776BB5A544CCEDFA005 + + fileRef + AC96F3646D94D164C6956ADF + isa + PBXBuildFile + + 7CC6A62356F712860A83645A isa PBXFileReference lastKnownFileType wrapper.framework name - Cocoa.framework + SystemConfiguration.framework path - Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Cocoa.framework + Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/SystemConfiguration.framework sourceTree DEVELOPER_DIR - 61CC8100380643D6AC901704 + 8350BA24D3852537D82617FC - fileRef - 7E7A27A0C7EE43E2B0CA3DD6 + includeInIndex + 1 isa - PBXBuildFile + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFURLResponseSerialization.m + path + AFNetworking/AFURLResponseSerialization.m + sourceTree + <group> + + 838F6142BF37BF556C11F454 + + explicitFileType + archive.ar + includeInIndex + 0 + isa + PBXFileReference + path + libPods-MASShortcut.a + sourceTree + BUILT_PRODUCTS_DIR - 63EC96E9D15A462E8C170512 + 83BE15F6D12B39088F1763D0 fileRef - 2A2A82B18D6D402E912E6BB3 + C5A5A2F63905CCD4D939A76E isa PBXBuildFile - settings - - COMPILER_FLAGS - -fobjc-arc -DOS_OBJECT_USE_OBJC=0 - - 66F0742E74774F7B8380F66B + 852004CC0AE2DCE040A3FEC0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MASShortcutView+Bindings.m + path + Framework/MASShortcutView+Bindings.m + sourceTree + <group> + + 859951AE86BEE3F952400F3E + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + Carbon.framework + path + Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Carbon.framework + sourceTree + DEVELOPER_DIR + + 85ACC9E07FDA4F65EA277590 + + children + + 66C8F8B682EE24852858B273 + A17DD57462CB25861290873E + ABB6153507EEA47FC544429E + 8350BA24D3852537D82617FC + + isa + PBXGroup + name + Serialization + sourceTree + <group> + + 8731277ACC741CFC8E3F961E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcutMonitor.h + path + Framework/MASShortcutMonitor.h + sourceTree + <group> + + 87DE16BB0C269FD655ABB3EC fileRef - F7E1621783D241D6B4942C0C + 3B7B456DBC42C08FB825B327 isa PBXBuildFile - 66F63BD9200348DB91A705DC + 8A5664D49F1243587E09666A + + includeInIndex + 1 + isa + PBXFileReference + name + base64.c + path + SocketRocket/base64.c + sourceTree + <group> + + 8AB5EB9A4B1ED7C4BCF910EF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFHTTPSessionManager.h + path + AFNetworking/AFHTTPSessionManager.h + sourceTree + <group> + + 8B531D307B6C41CC01E5F43E + + buildConfigurations + + A3F4CF08CE20D690349CA353 + C5CF91D5A2C9A7D3D65359E4 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 90280D34A96E8520686586AB includeInIndex 1 @@ -686,46 +1634,124 @@ PBXFileReference lastKnownFileType sourcecode.c.objc + name + MASShortcut.m path - Pods-MASShortcut-dummy.m + Framework/MASShortcut.m sourceTree <group> - 6A2570E0643D4268A8FB0CAD + 90D29D8055F76385F84389CE children - F7E1621783D241D6B4942C0C - 41DD136B0EDB4EF7993F7634 - 50CA7B8E6E5C4602A2AEC1D9 - 7248F3AA1804468796DC10CD - 6EEB1B00C1BB40258C822BBB - 067B5AFA614548C3A4B8600D - 18B20D19FDE54DA0B9CDF522 + 41CD9C6F6E79D12267678F25 isa PBXGroup name - SocketRocket + Frameworks + sourceTree + <group> + + 911BF526CA75F14D597ED4D2 + + children + + A1F39FD360A51DAD0F78843D + CAC4F4C4B47AA8189CC37108 + 0EE1F4CF5CF11894F3E935C5 + 96F6E29C6212687390F7AD76 + 5D866178A310F60C0B18847E + 73FC8B0BE2E829A7DFA1D3AF + 90280D34A96E8520686586AB + 446F81E58F55BC1155C74F14 + FC13E3108DD3418B09902341 + 8731277ACC741CFC8E3F961E + EBBE9626ED9FE968AD19B788 + 77F83B2ADD0808355BFC7C68 + C557E09D55875091522BBD26 + 2018C4EEA6BD9268C94FDE31 + FEB5DDEA35BB8EB7C89389B2 + AC96F3646D94D164C6956ADF + 852004CC0AE2DCE040A3FEC0 + 95D66E5BF7BF9D669C8F7DAA + 37C72163976E1E194A280CAB + + isa + PBXGroup + name + MASShortcut + path + MASShortcut + sourceTree + <group> + + 91FFBFBBECDFFA585DCAF00D + + fileRef + AA717EFA3A7D87E92C41DFBB + isa + PBXBuildFile + + 929F064F7A9AE290E11918AC + + fileRef + 66C8F8B682EE24852858B273 + isa + PBXBuildFile + + 9334DA37930E74A085F9E7C4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLSessionManager.h + path + AFNetworking/AFURLSessionManager.h + sourceTree + <group> + + 95315624722C94232CD00EFE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc path - SocketRocket + Pods-SocketRocket-dummy.m sourceTree <group> - 6EEB1B00C1BB40258C822BBB + 9561DBF7E29F2104E6F30A02 + + fileRef + 77F83B2ADD0808355BFC7C68 + isa + PBXBuildFile + + 95D66E5BF7BF9D669C8F7DAA includeInIndex 1 isa PBXFileReference + lastKnownFileType + sourcecode.c.h name - base64.c + Shortcut.h path - SocketRocket/base64.c + Framework/Shortcut.h sourceTree <group> - 7248F3AA1804468796DC10CD + 96F6E29C6212687390F7AD76 includeInIndex 1 @@ -734,90 +1760,103 @@ lastKnownFileType sourcecode.c.objc name - SRWebSocket.m + MASHotKey.m path - SocketRocket/SRWebSocket.m + Framework/MASHotKey.m sourceTree <group> - 73E6F0BD07DE451AAB74A349 + 976DEF42578884FCD507CA95 + explicitFileType + archive.ar includeInIndex - 1 + 0 isa PBXFileReference - lastKnownFileType - text.xcconfig path - Pods-SocketRocket.xcconfig + libPods.a sourceTree - <group> + BUILT_PRODUCTS_DIR + + 99CB3DF62DB1AA68187AE308 + + fileRef + F42872FD6DF4CE8BE89C4AC6 + isa + PBXBuildFile - 7926A797657942059A0B8372 + 9A70740C1D0CBA9114202261 children - 7D4A56861F304621A20B2E9C - 11A98F2EB6B3481DA38DEF2A - 173FCDC593354E51A65D6D53 - BE2E82420A824DA9996B968C - 9C57D7B2FBF5484A883A2622 - E8A5199EF2BB4C6D83FFDF41 - E681E0C53C4F4DE1B62D5CC9 - E333450803474B5B9AD4CA19 - 9A4264A8071D426091CA60E9 - 2A2A82B18D6D402E912E6BB3 - E1FFB4A06278427E86B0E3B5 + 1DA5A047182D9CA95D4B6A1F + D6BE5FF9A3CC35D98BEB1CA3 + 56C1D08DB4D6B945B40754A0 + F31B278A19D334ED57BE2AB3 + 5B61F8B08AB31EBD8E169B1A + 1F498CE74B75328E2F3AC128 + 30F86373A49B0580F4DE1A13 isa PBXGroup name - MASShortcut + Pods path - MASShortcut + Target Support Files/Pods sourceTree <group> - 7B00A0E255914BEABC074544 + 9B366904CDE9B4BCE13830C4 buildActionMask 2147483647 files - 827338A665CC4809B8554793 - E8D939BF241947E2AD0DAB1D + A62ADD4DE5F9C184C0B11310 + 279FC7B1A626599A39AC9F3F + 83BE15F6D12B39088F1763D0 + 3AFE0AE8545CA00791858A02 + 0F152C6337CF3415E7D19F67 + C7C6B0F783C1ED3464892312 + AD44BEF4DE96033320201081 + 4F59C346221EE132566D9B0D + 68A93585CE67991AEDD920BF + 63EA81A331BB2DD47FAE2FFE isa - PBXFrameworksBuildPhase + PBXSourcesBuildPhase runOnlyForDeploymentPostprocessing 0 - 7D4A56861F304621A20B2E9C + A03F728ED0C64CB5D638004F - includeInIndex - 1 + children + + C79BEA36F26FE24AC98F3F5D + 911BF526CA75F14D597ED4D2 + 3CB980EF73542D6D4B2A0371 + isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - MASShortcut.h + PBXGroup + name + Pods sourceTree <group> - 7D7DE236D57A462698608BD7 + A0AD1DBA7DD19A3451CAB9E3 fileRef - 41DD136B0EDB4EF7993F7634 + A87AB2F4C80345F28E6968A7 isa PBXBuildFile settings COMPILER_FLAGS - -fobjc-arc -DOS_OBJECT_USE_OBJC=0 + -DOS_OBJECT_USE_OBJC=0 - 7E7A27A0C7EE43E2B0CA3DD6 + A17DD57462CB25861290873E includeInIndex 1 @@ -825,15 +1864,32 @@ PBXFileReference lastKnownFileType sourcecode.c.objc + name + AFURLRequestSerialization.m path - Pods-dummy.m + AFNetworking/AFURLRequestSerialization.m + sourceTree + <group> + + A1F39FD360A51DAD0F78843D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASDictionaryTransformer.h + path + Framework/MASDictionaryTransformer.h sourceTree <group> - 7FF31F505E114C1483DED84B + A3F4CF08CE20D690349CA353 baseConfigurationReference - 8E53D6E736E34C82A8A6CBB6 + 6294203A87829A690C4EBD59 buildSettings ALWAYS_SEARCH_USER_PATHS @@ -846,8 +1902,6 @@ NO DSTROOT /tmp/xcodeproj.dst - GCC_C_LANGUAGE_STANDARD - gnu99 GCC_DYNAMIC_NO_PIC NO GCC_ENABLE_OBJC_EXCEPTIONS @@ -857,7 +1911,7 @@ GCC_PRECOMPILE_PREFIX_HEADER YES GCC_PREFIX_HEADER - Pods-MASShortcut-prefix.pch + Target Support Files/Pods-MASShortcut/Pods-MASShortcut-prefix.pch GCC_PREPROCESSOR_DEFINITIONS DEBUG=1 @@ -873,6 +1927,8 @@ 10.8 OTHER_LDFLAGS + OTHER_LIBTOOLFLAGS + PRODUCT_NAME $(TARGET_NAME) SDKROOT @@ -885,28 +1941,35 @@ name Debug - 827338A665CC4809B8554793 + A443DE3DA6A946ED34CA0D9B fileRef - 46DF5D8B2F0B440C8880417A + 56C1D08DB4D6B945B40754A0 isa PBXBuildFile - 8A25C0070324446E98E965FD + A44F4517224E2DF313304318 - fileRef - 589D5C4960814756994567B9 + children + + 3B3E43346A66F782AADF36F7 + 455E4DD4EC90D46BEB55CBE7 + isa - PBXBuildFile + PBXGroup + name + Security + sourceTree + <group> - 8BFEDC3EB230468A8EAE8E8D + A62ADD4DE5F9C184C0B11310 fileRef - 66F63BD9200348DB91A705DC + F5CBB13A080CD6B66398D31B isa PBXBuildFile - 8C76A65BCCEB4A028E596156 + A87AB2F4C80345F28E6968A7 includeInIndex 1 @@ -914,53 +1977,191 @@ PBXFileReference lastKnownFileType sourcecode.c.objc + name + NSData+SRB64Additions.m path - Pods-SocketRocket-dummy.m + SocketRocket/NSData+SRB64Additions.m sourceTree <group> - 8E53D6E736E34C82A8A6CBB6 + AA717EFA3A7D87E92C41DFBB + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + Cocoa.framework + path + Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Cocoa.framework + sourceTree + DEVELOPER_DIR + + ABB6153507EEA47FC544429E includeInIndex 1 isa PBXFileReference lastKnownFileType - text.xcconfig + sourcecode.c.h + name + AFURLResponseSerialization.h path - Pods-MASShortcut-Private.xcconfig + AFNetworking/AFURLResponseSerialization.h sourceTree <group> - 8FEED127C4CD4F8DA75E972C + AC96F3646D94D164C6956ADF - buildConfigurationList - 0E9FCAE734234F488A4A8DAB - buildPhases + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MASShortcutView+Bindings.h + path + Framework/MASShortcutView+Bindings.h + sourceTree + <group> + + AD44BEF4DE96033320201081 + + fileRef + A17DD57462CB25861290873E + isa + PBXBuildFile + + AEF743F9568F5F83368C49DC + + children - D54551D3BA1A464095151334 - D36E8E7A694846F0B17F7733 - 2649764896F84E9FB0DA5999 + 90D29D8055F76385F84389CE + A03F728ED0C64CB5D638004F + 133057AF82EACBC481FE9983 + 1FDC10D1BB0BACAF523B9DF8 - buildRules - - dependencies - isa - PBXNativeTarget + PBXGroup + sourceTree + <group> + + AF4E47973F9F54CFB3277BCD + + fileRef + 6859FD10D8DCB55C0E834977 + isa + PBXBuildFile + + B1A2C145D1AE6906AB785AC3 + + buildConfigurations + + 43EA72092035037EA38B9DC9 + C4213BF9A717C76DA09EE772 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + B2EC8AE43BE1D1D2661E0D13 + + buildActionMask + 2147483647 + files + + 2ED67259152D93AF9A2C09E4 + F25C77C168CF89FE5EA5CFC6 + 0CA0C4D365D576E0C5218A66 + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + B4398985227AEF90E5A36DE0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-SocketRocket.xcconfig + sourceTree + <group> + + B46ADF10CDEA193639DCF637 + + fileRef + FC13E3108DD3418B09902341 + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + B47447B5B1000FAD7FCBAA65 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc name - Pods-SocketRocket - productName - Pods-SocketRocket - productReference - 05F055A36872408A8F3D3710 - productType - com.apple.product-type.library.static + AFURLConnectionOperation.m + path + AFNetworking/AFURLConnectionOperation.m + sourceTree + <group> + + B70C8FA4CF04CD8A424248EF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + NSData+SRB64Additions.h + path + SocketRocket/NSData+SRB64Additions.h + sourceTree + <group> + + BCFC8F28DF65AB9D5D6441FD + + fileRef + 7CC6A62356F712860A83645A + isa + PBXBuildFile + + BD7A9D17C866685887EF5955 + + fileRef + 852004CC0AE2DCE040A3FEC0 + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + - 91F37B6C62384F9DA35EA92E + C4213BF9A717C76DA09EE772 baseConfigurationReference - 8E53D6E736E34C82A8A6CBB6 + 3DCD509F2E242A7087CBBF9D buildSettings ALWAYS_SEARCH_USER_PATHS @@ -975,14 +2176,12 @@ dwarf-with-dsym DSTROOT /tmp/xcodeproj.dst - GCC_C_LANGUAGE_STANDARD - gnu99 GCC_ENABLE_OBJC_EXCEPTIONS YES GCC_PRECOMPILE_PREFIX_HEADER YES GCC_PREFIX_HEADER - Pods-MASShortcut-prefix.pch + Target Support Files/Pods-SocketRocket/Pods-SocketRocket-prefix.pch GCC_VERSION com.apple.compilers.llvm.clang.1_0 INSTALL_PATH @@ -1001,6 +2200,8 @@
OTHER_LDFLAGS + OTHER_LIBTOOLFLAGS + PRODUCT_NAME $(TARGET_NAME) SDKROOT @@ -1013,80 +2214,40 @@ name Release - 9A029CBACA5E411B9CEA1715 - - isa - PBXFileReference - lastKnownFileType - wrapper.framework - name - Security.framework - path - Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Security.framework - sourceTree - DEVELOPER_DIR - - 9A4264A8071D426091CA60E9 - - includeInIndex - 1 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - MASShortcutView+UserDefaults.h - sourceTree - <group> - - 9AEA02CBFF10497CAD28E3B8 - - buildActionMask - 2147483647 - files - - D74F2B97F5104904BDD8A908 - D6A49F46FB864C278D3C0C1B - ACE3B20E1A364B97A7076165 - 63EC96E9D15A462E8C170512 - B197C2E9948E4F25B1F7CD09 - 8BFEDC3EB230468A8EAE8E8D - - isa - PBXSourcesBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - 9C57D7B2FBF5484A883A2622 + C557E09D55875091522BBD26 includeInIndex 1 isa PBXFileReference lastKnownFileType - sourcecode.c.h + sourcecode.c.objc + name + MASShortcutValidator.m path - MASShortcut+UserDefaults.h + Framework/MASShortcutValidator.m sourceTree <group> - 9ED6AC70029843ECBD5272EA + C5A5A2F63905CCD4D939A76E includeInIndex 1 isa PBXFileReference lastKnownFileType - text + sourcecode.c.objc + name + AFHTTPSessionManager.m path - Pods-acknowledgements.markdown + AFNetworking/AFHTTPSessionManager.m sourceTree <group> - A76340211D9B46B4BCE3C2E5 + C5CF91D5A2C9A7D3D65359E4 baseConfigurationReference - BFFB8C08134544689BF47835 + 6294203A87829A690C4EBD59 buildSettings ALWAYS_SEARCH_USER_PATHS @@ -1101,12 +2262,12 @@ dwarf-with-dsym DSTROOT /tmp/xcodeproj.dst - GCC_C_LANGUAGE_STANDARD - gnu99 GCC_ENABLE_OBJC_EXCEPTIONS YES GCC_PRECOMPILE_PREFIX_HEADER YES + GCC_PREFIX_HEADER + Target Support Files/Pods-MASShortcut/Pods-MASShortcut-prefix.pch GCC_VERSION com.apple.compilers.llvm.clang.1_0 INSTALL_PATH @@ -1125,6 +2286,8 @@ OTHER_LDFLAGS + OTHER_LIBTOOLFLAGS + PRODUCT_NAME $(TARGET_NAME) SDKROOT @@ -1137,123 +2300,49 @@ name Release - A847C3FC21BF4C128E47CE1D + C61F1F1D536FC245B3025FC0 - buildActionMask - 2147483647 - files - - 0C86D40D1EAB4568AC2CD8FF - C2C9F7450FCB49CB84E6D93A - D9559A8499DE4E4AABFB0957 - DCE7B607270544558C34A38D - B820D0A56018465CBBDA3BBE - + fileRef + ABB6153507EEA47FC544429E isa - PBXHeadersBuildPhase - runOnlyForDeploymentPostprocessing - 0 + PBXBuildFile - A91D927FF73E4840BBCE096F + C675DA9C092A11E98AB975B9 fileRef - 7248F3AA1804468796DC10CD + AA717EFA3A7D87E92C41DFBB isa PBXBuildFile - settings - - COMPILER_FLAGS - -fobjc-arc -DOS_OBJECT_USE_OBJC=0 - - A966E25F7C844BA7B423AD2C + C79BEA36F26FE24AC98F3F5D children - 1470DC568B4849BB8C570478 + 3E6D8408B0648E2A2B779F96 + 598618FF853C755C9483322D + 675D41B14F38679544A34919 + 3C9EAEA1B70A64643C08CEF2 + A44F4517224E2DF313304318 + 85ACC9E07FDA4F65EA277590 + 1FEA81A48CEFC5D40B38021A isa PBXGroup name - Frameworks - sourceTree - <group> - - AA94D76D2B81455986D0E8BF - - isa - PBXFileReference - lastKnownFileType - wrapper.framework - name - CoreServices.framework + AFNetworking path - Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreServices.framework + AFNetworking sourceTree - DEVELOPER_DIR - - ACE3B20E1A364B97A7076165 - - fileRef - 11A98F2EB6B3481DA38DEF2A - isa - PBXBuildFile - settings - - COMPILER_FLAGS - -fobjc-arc -DOS_OBJECT_USE_OBJC=0 - - - B197C2E9948E4F25B1F7CD09 - - fileRef - E333450803474B5B9AD4CA19 - isa - PBXBuildFile - settings - - COMPILER_FLAGS - -fobjc-arc -DOS_OBJECT_USE_OBJC=0 - - - B29CCF39CA94499F92639377 - - buildConfigurations - - 40BA25B286754649884B1995 - 48927BABFD3749D0BACCC9CB - - defaultConfigurationIsVisible - 0 - defaultConfigurationName - Release - isa - XCConfigurationList - - B364D5500278412EABA7BCA8 - - isa - PBXTargetDependency - target - 1165A5060BA94500B9EAD786 - targetProxy - CE4FEDDD5EFD4D699411D288 - - B7454E8765144522A23A284F - - fileRef - AA94D76D2B81455986D0E8BF - isa - PBXBuildFile + <group> - B820D0A56018465CBBDA3BBE + C7C6B0F783C1ED3464892312 fileRef - E681E0C53C4F4DE1B62D5CC9 + B47447B5B1000FAD7FCBAA65 isa PBXBuildFile - BE2E82420A824DA9996B968C + CAC4F4C4B47AA8189CC37108 includeInIndex 1 @@ -1261,289 +2350,121 @@ PBXFileReference lastKnownFileType sourcecode.c.objc - path - MASShortcut+Monitoring.m - sourceTree - <group> - - BF91D2B3B0614445AD297611 - - buildConfigurationList - 12F3191829B04C05940486EF - buildPhases - - F49CC6F0F38F4FB78CBA1F15 - 57D3A927F6A04192BBCC03E0 - - buildRules - - dependencies - - B364D5500278412EABA7BCA8 - ED71D0BA8FB644B2968F8797 - - isa - PBXNativeTarget name - Pods - productName - Pods - productReference - D40E833870214E3C9A8B4476 - productType - com.apple.product-type.library.static - - BFFB8C08134544689BF47835 - - includeInIndex - 1 - isa - PBXFileReference - lastKnownFileType - text.xcconfig + MASDictionaryTransformer.m path - Pods.xcconfig - sourceTree - <group> - - C088DAB27C1C4363A84B987B - - fileRef - 589D5C4960814756994567B9 - isa - PBXBuildFile - - C23B469BE8E54872A422417F - - children - - A966E25F7C844BA7B423AD2C - 15642AD9595B4EDDAC09D7F6 - 082BCE6468734DC49CA21092 - E64199CBF02B453DBD34856E - - isa - PBXGroup + Framework/MASDictionaryTransformer.m sourceTree <group> - C2C9F7450FCB49CB84E6D93A - - fileRef - 9C57D7B2FBF5484A883A2622 - isa - PBXBuildFile - - C6CE6A2E4FE1450A9E03AFF0 - - fileRef - 05F055A36872408A8F3D3710 - isa - PBXBuildFile - - CDA2050D0157400E9C058312 - - explicitFileType - archive.ar - includeInIndex - 0 - isa - PBXFileReference - path - libPods-MASShortcut.a - sourceTree - BUILT_PRODUCTS_DIR - - CE4FEDDD5EFD4D699411D288 - - containerPortal - 2EBF5D4433BF42D1A6D39878 - isa - PBXContainerItemProxy - proxyType - 1 - remoteGlobalIDString - 1165A5060BA94500B9EAD786 - remoteInfo - Pods-MASShortcut - - D36E8E7A694846F0B17F7733 - - buildActionMask - 2147483647 - files - - 8A25C0070324446E98E965FD - B7454E8765144522A23A284F - F1963073CD894C65AE3A3F93 - - isa - PBXFrameworksBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - D40E833870214E3C9A8B4476 - - explicitFileType - archive.ar - includeInIndex - 0 - isa - PBXFileReference - path - libPods.a - sourceTree - BUILT_PRODUCTS_DIR - - D54551D3BA1A464095151334 - - buildActionMask - 2147483647 - files - - 7D7DE236D57A462698608BD7 - E951003D860640779180CD2D - A91D927FF73E4840BBCE096F - F048119039654E45A85E477D - - isa - PBXSourcesBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - D6A49F46FB864C278D3C0C1B + CAD84EF0A5F6A251129D4E62 fileRef - E8A5199EF2BB4C6D83FFDF41 + 95D66E5BF7BF9D669C8F7DAA isa PBXBuildFile - settings - - COMPILER_FLAGS - -fobjc-arc -DOS_OBJECT_USE_OBJC=0 - - D74F2B97F5104904BDD8A908 + CD82EC24C311F1CA4472DAD1 - fileRef - BE2E82420A824DA9996B968C - isa - PBXBuildFile - settings + baseConfigurationReference + 1CB7418B8FA2AEB1A7ACAB3D + buildSettings - COMPILER_FLAGS - -fobjc-arc -DOS_OBJECT_USE_OBJC=0 - - - D9559A8499DE4E4AABFB0957 - - fileRef - 7D4A56861F304621A20B2E9C - isa - PBXBuildFile - - DCE7B607270544558C34A38D - - fileRef - 9A4264A8071D426091CA60E9 - isa - PBXBuildFile - - E1FFB4A06278427E86B0E3B5 - - children - - 11A662FC31584CCCAA7BE2E1 - 8E53D6E736E34C82A8A6CBB6 - 66F63BD9200348DB91A705DC - 02B0BD60483D46D6AFE364E5 - - isa - PBXGroup - name - Support Files - sourceTree - SOURCE_ROOT - - E333450803474B5B9AD4CA19 - - includeInIndex - 1 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - MASShortcutView.m - sourceTree - <group> - - E64199CBF02B453DBD34856E - - children - - 03C462AC59934C9F875A7D79 - + ALWAYS_SEARCH_USER_PATHS + NO + ARCHS + $(ARCHS_STANDARD_64_BIT) + COMBINE_HIDPI_IMAGES + YES + COPY_PHASE_STRIP + NO + DSTROOT + /tmp/xcodeproj.dst + GCC_DYNAMIC_NO_PIC + NO + GCC_ENABLE_OBJC_EXCEPTIONS + YES + GCC_OPTIMIZATION_LEVEL + 0 + GCC_PRECOMPILE_PREFIX_HEADER + YES + GCC_PREFIX_HEADER + Target Support Files/Pods-AFNetworking/Pods-AFNetworking-prefix.pch + GCC_PREPROCESSOR_DEFINITIONS + + DEBUG=1 + $(inherited) + + GCC_SYMBOLS_PRIVATE_EXTERN + NO + GCC_VERSION + com.apple.compilers.llvm.clang.1_0 + INSTALL_PATH + $(BUILT_PRODUCTS_DIR) + MACOSX_DEPLOYMENT_TARGET + 10.8 + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PRODUCT_NAME + $(TARGET_NAME) + SDKROOT + macosx + SKIP_INSTALL + YES + isa - PBXGroup + XCBuildConfiguration name - Targets Support Files - sourceTree - <group> + Debug - E681E0C53C4F4DE1B62D5CC9 + CE3250763B9346E46A764214 - includeInIndex - 1 isa PBXFileReference lastKnownFileType - sourcecode.c.h + wrapper.framework + name + AppKit.framework path - MASShortcutView.h + Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/AppKit.framework sourceTree - <group> + DEVELOPER_DIR - E8A5199EF2BB4C6D83FFDF41 + CEF2788FC4AB4868B1CD07B9 includeInIndex 1 isa PBXFileReference lastKnownFileType - sourcecode.c.objc + sourcecode.c.h path - MASShortcut+UserDefaults.m + Pods-AFNetworking-prefix.pch sourceTree <group> - E8D939BF241947E2AD0DAB1D - - fileRef - 589D5C4960814756994567B9 - isa - PBXBuildFile - - E951003D860640779180CD2D - - fileRef - 8C76A65BCCEB4A028E596156 - isa - PBXBuildFile - - ED71D0BA8FB644B2968F8797 + CFDD3892BC0A27350F1F4BD4 + buildActionMask + 2147483647 + files + + A0AD1DBA7DD19A3451CAB9E3 + 52F9DD000F2884866FC319C6 + 350A2E85F1B3F45E4FF28A5E + 45B1AC4BA1FB1853E12E0555 + isa - PBXTargetDependency - target - 8FEED127C4CD4F8DA75E972C - targetProxy - 150FBA295FBB4012B799B5AC + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 - EF1F15C1B8104423B741509F + CFFD034D48D8E40859B1760A baseConfigurationReference - BFFB8C08134544689BF47835 + 1F498CE74B75328E2F3AC128 buildSettings ALWAYS_SEARCH_USER_PATHS @@ -1556,8 +2477,6 @@ NO DSTROOT /tmp/xcodeproj.dst - GCC_C_LANGUAGE_STANDARD - gnu99 GCC_DYNAMIC_NO_PIC NO GCC_ENABLE_OBJC_EXCEPTIONS @@ -1581,6 +2500,8 @@ 10.8 OTHER_LDFLAGS + OTHER_LIBTOOLFLAGS + PRODUCT_NAME $(TARGET_NAME) SDKROOT @@ -1593,42 +2514,105 @@ name Debug - F048119039654E45A85E477D + D23B559BC654D3B27DAC9DC0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLConnectionOperation.h + path + AFNetworking/AFURLConnectionOperation.h + sourceTree + <group> + + D4D2CA2F0DEC94BA2E27C7A6 fileRef - 6EEB1B00C1BB40258C822BBB + AA717EFA3A7D87E92C41DFBB isa PBXBuildFile - settings - - COMPILER_FLAGS - -fobjc-arc -DOS_OBJECT_USE_OBJC=0 - - F1963073CD894C65AE3A3F93 + D6BE5FF9A3CC35D98BEB1CA3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Pods-acknowledgements.plist + sourceTree + <group> + + DCC7D3D313B6849C4B9DA512 fileRef - 9A029CBACA5E411B9CEA1715 + A1F39FD360A51DAD0F78843D isa PBXBuildFile - F49CC6F0F38F4FB78CBA1F15 + E75E59D1196D669270B7798E - buildActionMask - 2147483647 - files - - 61CC8100380643D6AC901704 - isa - PBXSourcesBuildPhase - runOnlyForDeploymentPostprocessing - 0 + PBXTargetDependency + name + Pods-AFNetworking + target + 0F40D51E432D7E226B2DDF2F + targetProxy + 71ED18CA46AE8D1DE7FEDD04 + + EA0D9F3BC450D819E3310ADF + + fileRef + 2018C4EEA6BD9268C94FDE31 + isa + PBXBuildFile + + EAB85557CC83C2D7364ADF8E + + fileRef + 0EE1F4CF5CF11894F3E935C5 + isa + PBXBuildFile + + EB2DE1111901FEE19088EBE1 + + containerPortal + 45CD4D3C883901D270C6FF43 + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 3C3CC8B320510DD261C2B145 + remoteInfo + Pods-SocketRocket + + EBBE9626ED9FE968AD19B788 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MASShortcutMonitor.m + path + Framework/MASShortcutMonitor.m + sourceTree + <group> - F4A4D26907934A05A7BC6E95 + EDC6E4A24CBECABCD5E68915 baseConfigurationReference - 2B18B7DD0B314A48AEC299DF + 1CB7418B8FA2AEB1A7ACAB3D buildSettings ALWAYS_SEARCH_USER_PATHS @@ -1643,14 +2627,12 @@ dwarf-with-dsym DSTROOT /tmp/xcodeproj.dst - GCC_C_LANGUAGE_STANDARD - gnu99 GCC_ENABLE_OBJC_EXCEPTIONS YES GCC_PRECOMPILE_PREFIX_HEADER YES GCC_PREFIX_HEADER - Pods-SocketRocket-prefix.pch + Target Support Files/Pods-AFNetworking/Pods-AFNetworking-prefix.pch GCC_VERSION com.apple.compilers.llvm.clang.1_0 INSTALL_PATH @@ -1669,6 +2651,8 @@ OTHER_LDFLAGS + OTHER_LIBTOOLFLAGS + PRODUCT_NAME $(TARGET_NAME) SDKROOT @@ -1681,7 +2665,62 @@ name Release - F7E1621783D241D6B4942C0C + EF22A89320848BC05463F4A3 + + explicitFileType + archive.ar + includeInIndex + 0 + isa + PBXFileReference + path + libPods-AFNetworking.a + sourceTree + BUILT_PRODUCTS_DIR + + EFA41ED7CCC1BA6CCBB030E4 + + buildActionMask + 2147483647 + files + + 87DE16BB0C269FD655ABB3EC + 35A5DF67263BED3DEDFC735F + 2D115316728D1BD16D98EEEF + AF4E47973F9F54CFB3277BCD + 63CF08C574AD4F3B83D13E3E + 356F577B89948852E5ACA42C + 141AA15F5753B38BF666ECF7 + 929F064F7A9AE290E11918AC + C61F1F1D536FC245B3025FC0 + 63C57121D27447305EA32A1D + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + F1B2D2DC7E031CF249B25BC1 + + explicitFileType + archive.ar + includeInIndex + 0 + isa + PBXFileReference + path + libPods-SocketRocket.a + sourceTree + BUILT_PRODUCTS_DIR + + F25C77C168CF89FE5EA5CFC6 + + fileRef + 1F2687545C131592B068C24B + isa + PBXBuildFile + + F31B278A19D334ED57BE2AB3 includeInIndex 1 @@ -1689,22 +2728,131 @@ PBXFileReference lastKnownFileType sourcecode.c.h + path + Pods-environment.h + sourceTree + <group> + + F42872FD6DF4CE8BE89C4AC6 + + isa + PBXFileReference + lastKnownFileType + wrapper.framework name - NSData+SRB64Additions.h + Security.framework path - SocketRocket/NSData+SRB64Additions.h + Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Security.framework + sourceTree + DEVELOPER_DIR + + F56DD32A1209CF7A2AA284E8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFURLSessionManager.m + path + AFNetworking/AFURLSessionManager.m + sourceTree + <group> + + F57E5F8329878AD44B101BA1 + + buildActionMask + 2147483647 + files + + DCC7D3D313B6849C4B9DA512 + EAB85557CC83C2D7364ADF8E + 2E96CEBE0F63120D7CD6184A + 58EEF5780FEB7F278CC894D0 + 4FE14DB0B4E78C22019E255A + 32220FC4502FF715AB7BE25A + 9561DBF7E29F2104E6F30A02 + 7A8BD776BB5A544CCEDFA005 + EA0D9F3BC450D819E3310ADF + CAD84EF0A5F6A251129D4E62 + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + F5CBB13A080CD6B66398D31B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFHTTPRequestOperation.m + path + AFNetworking/AFHTTPRequestOperation.m sourceTree <group> - FF4286A8004C427690982A9F + F8D644A2C51EC2AB7D5BAAB0 fileRef - CDA2050D0157400E9C058312 + 859951AE86BEE3F952400F3E isa PBXBuildFile + FC13E3108DD3418B09902341 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MASShortcutBinder.m + path + Framework/MASShortcutBinder.m + sourceTree + <group> + + FD40EC174BC339958657D7E7 + + buildActionMask + 2147483647 + files + + 5C98A90DC872F708AD6211DD + 6DC28C2A7A1762CE0069B404 + 789554EE8C9ED7F775A7B90F + BCFC8F28DF65AB9D5D6441FD + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + FEB5DDEA35BB8EB7C89389B2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MASShortcutView.m + path + Framework/MASShortcutView.m + sourceTree + <group> + rootObject - 2EBF5D4433BF42D1A6D39878 + 45CD4D3C883901D270C6FF43 diff --git a/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-AFNetworking.xcscheme b/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-AFNetworking.xcscheme new file mode 100644 index 0000000..497b051 --- /dev/null +++ b/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-AFNetworking.xcscheme @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-MASShortcut.xcscheme b/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-MASShortcut.xcscheme index 185a234..665bbe6 100644 --- a/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-MASShortcut.xcscheme +++ b/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-MASShortcut.xcscheme @@ -1,6 +1,6 @@ diff --git a/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-SocketRocket.xcscheme b/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-SocketRocket.xcscheme index 9108bf3..20f928b 100644 --- a/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-SocketRocket.xcscheme +++ b/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods-SocketRocket.xcscheme @@ -1,6 +1,6 @@ diff --git a/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods.xcscheme b/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods.xcscheme index a19c14b..3d029a2 100644 --- a/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods.xcscheme +++ b/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/Pods.xcscheme @@ -1,6 +1,6 @@ diff --git a/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/xcschememanagement.plist b/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/xcschememanagement.plist index ea74e61..e0d3550 100644 --- a/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/vendor/Pods/Pods.xcodeproj/xcuserdata/duncan.xcuserdatad/xcschemes/xcschememanagement.plist @@ -4,6 +4,11 @@ SchemeUserState + Pods-AFNetworking.xcscheme + + isShown + + Pods-MASShortcut.xcscheme isShown diff --git a/vendor/Pods/SocketRocket/README.rst b/vendor/Pods/SocketRocket/README.rst index 25f3026..2221810 100644 --- a/vendor/Pods/SocketRocket/README.rst +++ b/vendor/Pods/SocketRocket/README.rst @@ -16,32 +16,13 @@ Features/Design - TLS (wss) support. It uses CFStream so we get this for *free* - Uses NSStream/CFNetworking. Earlier implementations used ``dispatch_io``, however, this proved to be make TLS nearly impossible. Also I wanted this to - work in iOS 4.x. (SocketRocket only supports 5.0 and above now) + work in iOS 4.x. - Uses ARC. It uses the 4.0 compatible subset (no weak refs). - Seems to perform quite well - Parallel architecture. Most of the work is done in background worker queues. - Delegate-based. Had older versions that could use blocks too, but I felt it didn't blend well with retain cycles and just objective C in general. -Changes -------- - -v0.3.1-beta2 - 2013-01-12 -````````````````````````` - -- Stability fix for ``closeWithCode:reason:`` (Thanks @michaelpetrov!) -- Actually clean up the NSStreams and remove them from their runloops -- ``_SRRunLoopThread``'s ``main`` wasn't correctly wrapped with - ``@autoreleasepool`` - -v0.3.1-beta1 - 2013-01-12 -````````````````````````` - -- Cleaned up GCD so OS_OBJECT_USE_OBJC_RETAIN_RELEASE is optional -- Removed deprecated ``dispatch_get_current_queue`` in favor of ``dispatch_queue_set_specific`` and ``dispatch_get_specific`` -- Dropping support for iOS 4.0 (it may still work) - - Installing (iOS) ---------------- There's a few options. Choose one, or just figure it out diff --git a/vendor/Pods/SocketRocket/SocketRocket/NSData+SRB64Additions.h b/vendor/Pods/SocketRocket/SocketRocket/NSData+SRB64Additions.h index 7d61063..115108d 100644 --- a/vendor/Pods/SocketRocket/SocketRocket/NSData+SRB64Additions.h +++ b/vendor/Pods/SocketRocket/SocketRocket/NSData+SRB64Additions.h @@ -16,7 +16,6 @@ #import - @interface NSData (SRB64Additions) - (NSString *)SR_stringByBase64Encoding; diff --git a/vendor/Pods/SocketRocket/SocketRocket/NSData+SRB64Additions.m b/vendor/Pods/SocketRocket/SocketRocket/NSData+SRB64Additions.m index 5874a18..71bae3b 100644 --- a/vendor/Pods/SocketRocket/SocketRocket/NSData+SRB64Additions.m +++ b/vendor/Pods/SocketRocket/SocketRocket/NSData+SRB64Additions.m @@ -17,7 +17,6 @@ #import "NSData+SRB64Additions.h" #import "base64.h" - @implementation NSData (SRB64Additions) - (NSString *)SR_stringByBase64Encoding; diff --git a/vendor/Pods/SocketRocket/SocketRocket/SRWebSocket.h b/vendor/Pods/SocketRocket/SocketRocket/SRWebSocket.h index 2d40bb1..a7e1851 100644 --- a/vendor/Pods/SocketRocket/SocketRocket/SRWebSocket.h +++ b/vendor/Pods/SocketRocket/SocketRocket/SRWebSocket.h @@ -22,18 +22,15 @@ typedef enum { SR_OPEN = 1, SR_CLOSING = 2, SR_CLOSED = 3, + } SRReadyState; @class SRWebSocket; extern NSString *const SRWebSocketErrorDomain; -#pragma mark - SRWebSocketDelegate - @protocol SRWebSocketDelegate; -#pragma mark - SRWebSocket - @interface SRWebSocket : NSObject @property (nonatomic, assign) id delegate; @@ -42,43 +39,32 @@ extern NSString *const SRWebSocketErrorDomain; @property (nonatomic, readonly, retain) NSURL *url; // This returns the negotiated protocol. -// It will be nil until after the handshake completes. +// It will be niluntil after the handshake completes. @property (nonatomic, readonly, copy) NSString *protocol; -// Protocols should be an array of strings that turn into Sec-WebSocket-Protocol. +// Protocols should be an array of strings that turn into Sec-WebSocket-Protocol - (id)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols; - (id)initWithURLRequest:(NSURLRequest *)request; -// Some helper constructors. +// Some helper constructors - (id)initWithURL:(NSURL *)url protocols:(NSArray *)protocols; - (id)initWithURL:(NSURL *)url; -// Delegate queue will be dispatch_main_queue by default. -// You cannot set both OperationQueue and dispatch_queue. -- (void)setDelegateOperationQueue:(NSOperationQueue*) queue; -- (void)setDelegateDispatchQueue:(dispatch_queue_t) queue; - -// By default, it will schedule itself on +[NSRunLoop SR_networkRunLoop] using defaultModes. -- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; -- (void)unscheduleFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; - -// SRWebSockets are intended for one-time-use only. Open should be called once and only once. +// SRWebSockets are intended one-time-use only. Open should be called once and only once - (void)open; - (void)close; - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason; -// Send a UTF8 String or Data. +// Send a UTF8 String or Data - (void)send:(id)data; @end -#pragma mark - SRWebSocketDelegate - @protocol SRWebSocketDelegate -// message will either be an NSString if the server is using text -// or NSData if the server is using binary. +// message will either be an NSString if the server is using text +// or NSData if the server is using binary - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message; @optional @@ -89,7 +75,6 @@ extern NSString *const SRWebSocketErrorDomain; @end -#pragma mark - NSURLRequest (CertificateAdditions) @interface NSURLRequest (CertificateAdditions) @@ -97,18 +82,9 @@ extern NSString *const SRWebSocketErrorDomain; @end -#pragma mark - NSMutableURLRequest (CertificateAdditions) @interface NSMutableURLRequest (CertificateAdditions) @property (nonatomic, retain) NSArray *SR_SSLPinnedCertificates; @end - -#pragma mark - NSRunLoop (SRWebSocket) - -@interface NSRunLoop (SRWebSocket) - -+ (NSRunLoop *)SR_networkRunLoop; - -@end diff --git a/vendor/Pods/SocketRocket/SocketRocket/SRWebSocket.m b/vendor/Pods/SocketRocket/SocketRocket/SRWebSocket.m index 3c94137..ef7c65c 100644 --- a/vendor/Pods/SocketRocket/SocketRocket/SRWebSocket.m +++ b/vendor/Pods/SocketRocket/SocketRocket/SRWebSocket.m @@ -33,33 +33,17 @@ #import #import - #import "base64.h" #import "NSData+SRB64Additions.h" -#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE -#define sr_dispatch_retain(x) -#define sr_dispatch_release(x) -#define maybe_bridge(x) ((__bridge void *) x) -#else -#define sr_dispatch_retain(x) dispatch_retain(x) -#define sr_dispatch_release(x) dispatch_release(x) -#define maybe_bridge(x) (x) -#endif - -#if !__has_feature(objc_arc) -#error SocketRocket muust be compiled with ARC enabled -#endif - - typedef enum { SROpCodeTextFrame = 0x1, SROpCodeBinaryFrame = 0x2, - // 3-7 reserved. + //3-7Reserved SROpCodeConnectionClose = 0x8, SROpCodePing = 0x9, SROpCodePong = 0xA, - // B-F reserved. + //B-F reserved } SROpCode; typedef enum { @@ -67,9 +51,9 @@ SRStatusCodeGoingAway = 1001, SRStatusCodeProtocolError = 1002, SRStatusCodeUnhandledType = 1003, - // 1004 reserved. + // 1004 reserved SRStatusNoStatusReceived = 1005, - // 1004-1006 reserved. + // 1004-1006 reserved SRStatusCodeInvalidUTF8 = 1007, SRStatusCodePolicyViolated = 1008, SRStatusCodeMessageTooBig = 1009, @@ -107,20 +91,13 @@ - (NSString *)stringBySHA1ThenBase64Encoding; @interface NSURL (SRWebSocket) -// The origin isn't really applicable for a native application. -// So instead, just map ws -> http and wss -> https. +// The origin isn't really applicable for a native application +// So instead, just map ws -> http and wss -> https - (NSString *)SR_origin; @end -@interface _SRRunLoopThread : NSThread - -@property (nonatomic, readonly) NSRunLoop *runLoop; - -@end - - static NSString *newSHA1String(const char *bytes, size_t length) { uint8_t md[CC_SHA1_DIGEST_LENGTH]; @@ -160,7 +137,7 @@ - (NSString *)stringBySHA1ThenBase64Encoding; NSString *const SRWebSocketErrorDomain = @"SRWebSocketErrorDomain"; -// Returns number of bytes consumed. Returning 0 means you didn't match. +// Returns number of bytes consumed. returning 0 means you didn't match. // Sends bytes to callback handler; typedef size_t (^stream_scanner)(NSData *collected_data); @@ -173,6 +150,9 @@ @interface SRIOConsumer : NSObject { BOOL _readToCurrentFrame; BOOL _unmaskBytes; } + +- (id)initWithScanner:(stream_scanner)scanner handler:(data_callback)handler bytesNeeded:(size_t)bytesNeeded readToCurrentFrame:(BOOL)readToCurrentFrame unmaskBytes:(BOOL)unmaskBytes; + @property (nonatomic, copy, readonly) stream_scanner consumer; @property (nonatomic, copy, readonly) data_callback handler; @property (nonatomic, assign) size_t bytesNeeded; @@ -181,15 +161,6 @@ @interface SRIOConsumer : NSObject { @end -// This class is not thread-safe, and is expected to always be run on the same queue. -@interface SRIOConsumerPool : NSObject - -- (id)initWithBufferCapacity:(NSUInteger)poolSize; - -- (SRIOConsumer *)consumerWithScanner:(stream_scanner)scanner handler:(data_callback)handler bytesNeeded:(size_t)bytesNeeded readToCurrentFrame:(BOOL)readToCurrentFrame unmaskBytes:(BOOL)unmaskBytes; -- (void)returnConsumer:(SRIOConsumer *)consumer; - -@end @interface SRWebSocket () @@ -217,23 +188,16 @@ - (void)_sendFrameWithOpcode:(SROpCode)opcode data:(id)data; - (BOOL)_checkHandshake:(CFHTTPMessageRef)httpMessage; - (void)_SR_commonInit; -- (void)_initializeStreams; -- (void)_connect; +- (void)_connectToHost:(NSString *)host port:(NSInteger)port; @property (nonatomic) SRReadyState readyState; -@property (nonatomic) NSOperationQueue *delegateOperationQueue; -@property (nonatomic) dispatch_queue_t delegateDispatchQueue; - @end @implementation SRWebSocket { NSInteger _webSocketVersion; - - NSOperationQueue *_delegateOperationQueue; - dispatch_queue_t _delegateDispatchQueue; - + dispatch_queue_t _callbackQueue; dispatch_queue_t _workQueue; NSMutableArray *_consumers; @@ -241,10 +205,10 @@ @implementation SRWebSocket { NSOutputStream *_outputStream; NSMutableData *_readBuffer; - NSUInteger _readBufferOffset; + NSInteger _readBufferOffset; NSMutableData *_outputBuffer; - NSUInteger _outputBufferOffset; + NSInteger _outputBufferOffset; uint8_t _currentFrameOpcode; size_t _currentFrameCount; @@ -277,13 +241,10 @@ @implementation SRWebSocket { BOOL _isPumping; - NSMutableSet *_scheduledRunloops; - // We use this to retain ourselves. __strong SRWebSocket *_selfRetain; NSArray *_requestedProtocols; - SRIOConsumerPool *_consumerPool; } @synthesize delegate = _delegate; @@ -304,9 +265,16 @@ - (id)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols; if (self) { assert(request.URL); _url = request.URL; - _urlRequest = request; + NSString *scheme = [_url scheme]; _requestedProtocols = [protocols copy]; + + assert([scheme isEqualToString:@"ws"] || [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"wss"] || [scheme isEqualToString:@"https"]); + _urlRequest = request; + + if ([scheme isEqualToString:@"wss"] || [scheme isEqualToString:@"https"]) { + _secure = YES; + } [self _SR_commonInit]; } @@ -332,25 +300,16 @@ - (id)initWithURL:(NSURL *)url protocols:(NSArray *)protocols; - (void)_SR_commonInit; { - - NSString *scheme = _url.scheme.lowercaseString; - assert([scheme isEqualToString:@"ws"] || [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"wss"] || [scheme isEqualToString:@"https"]); - - if ([scheme isEqualToString:@"wss"] || [scheme isEqualToString:@"https"]) { - _secure = YES; - } - _readyState = SR_CONNECTING; + _consumerStopped = YES; + _webSocketVersion = 13; _workQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - // Going to set a specific on the queue so we can validate we're on the work queue - dispatch_queue_set_specific(_workQueue, (__bridge void *)self, maybe_bridge(_workQueue), NULL); - - _delegateDispatchQueue = dispatch_get_main_queue(); - sr_dispatch_retain(_delegateDispatchQueue); + _callbackQueue = dispatch_get_main_queue(); + dispatch_retain(_callbackQueue); _readBuffer = [[NSMutableData alloc] init]; _outputBuffer = [[NSMutableData alloc] init]; @@ -359,20 +318,9 @@ - (void)_SR_commonInit; _consumers = [[NSMutableArray alloc] init]; - _consumerPool = [[SRIOConsumerPool alloc] init]; - - _scheduledRunloops = [[NSMutableSet alloc] init]; - - [self _initializeStreams]; - // default handlers } -- (void)assertOnWorkQueue; -{ - assert(dispatch_get_specific((__bridge void *)self) == maybe_bridge(_workQueue)); -} - - (void)dealloc { _inputStream.delegate = nil; @@ -381,18 +329,13 @@ - (void)dealloc [_inputStream close]; [_outputStream close]; - sr_dispatch_release(_workQueue); - _workQueue = NULL; + dispatch_release(_callbackQueue); + dispatch_release(_workQueue); if (_receivedHTTPHeaders) { CFRelease(_receivedHTTPHeaders); _receivedHTTPHeaders = NULL; } - - if (_delegateDispatchQueue) { - sr_dispatch_release(_delegateDispatchQueue); - _delegateDispatchQueue = NULL; - } } #ifndef NDEBUG @@ -410,37 +353,24 @@ - (void)setReadyState:(SRReadyState)aReadyState; - (void)open; { assert(_url); - NSAssert(_readyState == SR_CONNECTING, @"Cannot call -(void)open on SRWebSocket more than once"); + NSAssert(_readyState == SR_CONNECTING && _inputStream == nil && _outputStream == nil, @"Cannot call -(void)open on SRWebSocket more than once"); _selfRetain = self; - [self _connect]; -} - -// Calls block on delegate queue -- (void)_performDelegateBlock:(dispatch_block_t)block; -{ - if (_delegateOperationQueue) { - [_delegateOperationQueue addOperationWithBlock:block]; - } else { - assert(_delegateDispatchQueue); - dispatch_async(_delegateDispatchQueue, block); + NSInteger port = _url.port.integerValue; + if (port == 0) { + if (!_secure) { + port = 80; + } else { + port = 443; + } } -} -- (void)setDelegateDispatchQueue:(dispatch_queue_t)queue; -{ - if (queue) { - sr_dispatch_retain(queue); - } - - if (_delegateDispatchQueue) { - sr_dispatch_release(_delegateDispatchQueue); - } - - _delegateDispatchQueue = queue; + [self _connectToHost:_url.host port:port]; } + + - (BOOL)_checkHandshake:(CFHTTPMessageRef)httpMessage; { NSString *acceptHeader = CFBridgingRelease(CFHTTPMessageCopyHeaderFieldValue(httpMessage, CFSTR("Sec-WebSocket-Accept"))); @@ -488,11 +418,11 @@ - (void)_HTTPHeadersDidFinish; [self _readFrameNew]; } - [self _performDelegateBlock:^{ + dispatch_async(_callbackQueue, ^{ if ([self.delegate respondsToSelector:@selector(webSocketDidOpen:)]) { [self.delegate webSocketDidOpen:self]; - }; - }]; + } + }); } @@ -550,18 +480,8 @@ - (void)didConnect [self _readHTTPHeader]; } -- (void)_initializeStreams; -{ - NSInteger port = _url.port.integerValue; - if (port == 0) { - if (!_secure) { - port = 80; - } else { - port = 443; - } - } - NSString *host = _url.host; - +- (void)_connectToHost:(NSString *)host port:(NSInteger)port; +{ CFReadStreamRef readStream = NULL; CFWriteStreamRef writeStream = NULL; @@ -573,7 +493,7 @@ - (void)_initializeStreams; if (_secure) { NSMutableDictionary *SSLOptions = [[NSMutableDictionary alloc] init]; - + [_outputStream setProperty:(__bridge id)kCFStreamSocketSecurityLevelNegotiatedSSL forKey:(__bridge id)kCFStreamPropertySocketSecurityLevel]; // If we're using pinned certs, don't validate the certificate chain @@ -581,10 +501,10 @@ - (void)_initializeStreams; [SSLOptions setValue:[NSNumber numberWithBool:NO] forKey:(__bridge id)kCFStreamSSLValidatesCertificateChain]; } -#if DEBUG + #if DEBUG [SSLOptions setValue:[NSNumber numberWithBool:NO] forKey:(__bridge id)kCFStreamSSLValidatesCertificateChain]; NSLog(@"SocketRocket: In debug mode. Allowing connection to any root cert"); -#endif + #endif [_outputStream setProperty:SSLOptions forKey:(__bridge id)kCFStreamPropertySSLSettings]; @@ -592,35 +512,16 @@ - (void)_initializeStreams; _inputStream.delegate = self; _outputStream.delegate = self; -} - -- (void)_connect; -{ - if (!_scheduledRunloops.count) { - [self scheduleInRunLoop:[NSRunLoop SR_networkRunLoop] forMode:NSDefaultRunLoopMode]; - } + + // TODO schedule in a better run loop + [_outputStream scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; + [_inputStream scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [_outputStream open]; [_inputStream open]; } -- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; -{ - [_outputStream scheduleInRunLoop:aRunLoop forMode:mode]; - [_inputStream scheduleInRunLoop:aRunLoop forMode:mode]; - - [_scheduledRunloops addObject:@[aRunLoop, mode]]; -} - -- (void)unscheduleFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; -{ - [_outputStream removeFromRunLoop:aRunLoop forMode:mode]; - [_inputStream removeFromRunLoop:aRunLoop forMode:mode]; - - [_scheduledRunloops removeObject:@[aRunLoop, mode]]; -} - - (void)close; { [self closeWithCode:-1 reason:nil]; @@ -629,17 +530,16 @@ - (void)close; - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason; { assert(code); + if (self.readyState == SR_CLOSING || self.readyState == SR_CLOSED) { + return; + } + + BOOL wasConnecting = self.readyState == SR_CONNECTING; + + self.readyState = SR_CLOSING; + + SRFastLog(@"Closing with code %d reason %@", code, reason); dispatch_async(_workQueue, ^{ - if (self.readyState == SR_CLOSING || self.readyState == SR_CLOSED) { - return; - } - - BOOL wasConnecting = self.readyState == SR_CONNECTING; - - self.readyState = SR_CLOSING; - - SRFastLog(@"Closing with code %d reason %@", code, reason); - if (wasConnecting) { [self _disconnect]; return; @@ -674,12 +574,12 @@ - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason; - (void)_closeWithProtocolError:(NSString *)message; { // Need to shunt this on the _callbackQueue first to see if they received any messages - [self _performDelegateBlock:^{ + dispatch_async(_callbackQueue, ^{ [self closeWithCode:SRStatusCodeProtocolError reason:message]; dispatch_async(_workQueue, ^{ [self _disconnect]; }); - }]; + }); } - (void)_failWithError:(NSError *)error; @@ -687,11 +587,11 @@ - (void)_failWithError:(NSError *)error; dispatch_async(_workQueue, ^{ if (self.readyState != SR_CLOSED) { _failed = YES; - [self _performDelegateBlock:^{ + dispatch_async(_callbackQueue, ^{ if ([self.delegate respondsToSelector:@selector(webSocket:didFailWithError:)]) { [self.delegate webSocket:self didFailWithError:error]; } - }]; + }); self.readyState = SR_CLOSED; _selfRetain = nil; @@ -705,7 +605,7 @@ - (void)_failWithError:(NSError *)error; - (void)_writeData:(NSData *)data; { - [self assertOnWorkQueue]; + assert(dispatch_get_current_queue() == _workQueue); if (_closeWhenFinishedWriting) { return; @@ -734,11 +634,11 @@ - (void)send:(id)data; - (void)handlePing:(NSData *)pingData; { // Need to pingpong this off _callbackQueue first to make sure messages happen in order - [self _performDelegateBlock:^{ + dispatch_async(_callbackQueue, ^{ dispatch_async(_workQueue, ^{ [self _sendFrameWithOpcode:SROpCodePong data:pingData]; }); - }]; + }); } - (void)handlePong; @@ -749,9 +649,9 @@ - (void)handlePong; - (void)_handleMessage:(id)message { SRFastLog(@"Received message"); - [self _performDelegateBlock:^{ + dispatch_async(_callbackQueue, ^{ [self.delegate webSocket:self didReceiveMessage:message]; - }]; + }); } @@ -818,7 +718,7 @@ - (void)handleCloseWithData:(NSData *)data; _closeCode = SRStatusNoStatusReceived; } - [self assertOnWorkQueue]; + assert(dispatch_get_current_queue() == _workQueue); if (self.readyState == SR_OPEN) { [self closeWithCode:1000 reason:nil]; @@ -830,7 +730,7 @@ - (void)handleCloseWithData:(NSData *)data; - (void)_disconnect; { - [self assertOnWorkQueue]; + assert(dispatch_get_current_queue() == _workQueue); SRFastLog(@"Trying to disconnect"); _closeWhenFinishedWriting = YES; [self _pumpWriting]; @@ -1065,11 +965,11 @@ - (void)_readFrameNew; - (void)_pumpWriting; { - [self assertOnWorkQueue]; + assert(dispatch_get_current_queue() == _workQueue); NSUInteger dataLength = _outputBuffer.length; if (dataLength - _outputBufferOffset > 0 && _outputStream.hasSpaceAvailable) { - NSInteger bytesWritten = [_outputStream write:_outputBuffer.bytes + _outputBufferOffset maxLength:dataLength - _outputBufferOffset]; + NSUInteger bytesWritten = [_outputStream write:_outputBuffer.bytes + _outputBufferOffset maxLength:dataLength - _outputBufferOffset]; if (bytesWritten == -1) { [self _failWithError:[NSError errorWithDomain:@"org.lolrus.SocketRocket" code:2145 userInfo:[NSDictionary dictionaryWithObject:@"Error writing to stream" forKey:NSLocalizedDescriptionKey]]]; return; @@ -1093,17 +993,12 @@ - (void)_pumpWriting; [_outputStream close]; [_inputStream close]; - - for (NSArray *runLoop in [_scheduledRunloops copy]) { - [self unscheduleFromRunLoop:[runLoop objectAtIndex:0] forMode:[runLoop objectAtIndex:1]]; - } - if (!_failed) { - [self _performDelegateBlock:^{ + dispatch_async(_callbackQueue, ^{ if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) { [self.delegate webSocket:self didCloseWithCode:_closeCode reason:_closeReason wasClean:YES]; } - }]; + }); } _selfRetain = nil; @@ -1112,23 +1007,23 @@ - (void)_pumpWriting; - (void)_addConsumerWithScanner:(stream_scanner)consumer callback:(data_callback)callback; { - [self assertOnWorkQueue]; + assert(dispatch_get_current_queue() == _workQueue); [self _addConsumerWithScanner:consumer callback:callback dataLength:0]; } - (void)_addConsumerWithDataLength:(size_t)dataLength callback:(data_callback)callback readToCurrentFrame:(BOOL)readToCurrentFrame unmaskBytes:(BOOL)unmaskBytes; { - [self assertOnWorkQueue]; + assert(dispatch_get_current_queue() == _workQueue); assert(dataLength); - [_consumers addObject:[_consumerPool consumerWithScanner:nil handler:callback bytesNeeded:dataLength readToCurrentFrame:readToCurrentFrame unmaskBytes:unmaskBytes]]; + [_consumers addObject:[[SRIOConsumer alloc] initWithScanner:nil handler:callback bytesNeeded:dataLength readToCurrentFrame:readToCurrentFrame unmaskBytes:unmaskBytes]]; [self _pumpScanner]; } - (void)_addConsumerWithScanner:(stream_scanner)consumer callback:(data_callback)callback dataLength:(size_t)dataLength; { - [self assertOnWorkQueue]; - [_consumers addObject:[_consumerPool consumerWithScanner:consumer handler:callback bytesNeeded:dataLength readToCurrentFrame:NO unmaskBytes:NO]]; + assert(dispatch_get_current_queue() == _workQueue); + [_consumers addObject:[[SRIOConsumer alloc] initWithScanner:consumer handler:callback bytesNeeded:dataLength readToCurrentFrame:NO unmaskBytes:NO]]; [self _pumpScanner]; } @@ -1149,7 +1044,7 @@ - (void)_readUntilBytes:(const void *)bytes length:(size_t)length callback:(data size_t size = data.length; const unsigned char *buffer = data.bytes; - for (size_t i = 0; i < size; i++ ) { + for (int i = 0; i < size; i++ ) { if (((const unsigned char *)buffer)[i] == ((const unsigned char *)bytes)[match_count]) { match_count += 1; if (match_count == length) { @@ -1218,7 +1113,7 @@ - (BOOL)_innerPumpScanner { NSUInteger len = mutableSlice.length; uint8_t *bytes = mutableSlice.mutableBytes; - for (NSUInteger i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { bytes[i] = bytes[i] ^ _currentReadMaskKey[_currentReadMaskOffset % sizeof(_currentReadMaskKey)]; _currentReadMaskOffset += 1; } @@ -1260,13 +1155,11 @@ - (BOOL)_innerPumpScanner { if (consumer.bytesNeeded == 0) { [_consumers removeObjectAtIndex:0]; consumer.handler(self, nil); - [_consumerPool returnConsumer:consumer]; didWork = YES; } } else if (foundSize) { [_consumers removeObjectAtIndex:0]; consumer.handler(self, slice); - [_consumerPool returnConsumer:consumer]; didWork = YES; } } @@ -1275,7 +1168,7 @@ - (BOOL)_innerPumpScanner { -(void)_pumpScanner; { - [self assertOnWorkQueue]; + assert(dispatch_get_current_queue() == _workQueue); if (!_isPumping) { _isPumping = YES; @@ -1296,7 +1189,7 @@ -(void)_pumpScanner; - (void)_sendFrameWithOpcode:(SROpCode)opcode data:(id)data; { - [self assertOnWorkQueue]; + assert(dispatch_get_current_queue() == _workQueue); NSAssert(data == nil || [data isKindOfClass:[NSData class]] || [data isKindOfClass:[NSString class]], @"Function expects nil, NSString or NSData"); @@ -1346,7 +1239,7 @@ - (void)_sendFrameWithOpcode:(SROpCode)opcode data:(id)data; } if (!useMask) { - for (size_t i = 0; i < payloadLength; i++) { + for (int i = 0; i < payloadLength; i++) { frame_buffer[frame_buffer_size] = unmasked_payload[i]; frame_buffer_size += 1; } @@ -1356,7 +1249,7 @@ - (void)_sendFrameWithOpcode:(SROpCode)opcode data:(id)data; frame_buffer_size += sizeof(uint32_t); // TODO: could probably optimize this with SIMD - for (size_t i = 0; i < payloadLength; i++) { + for (int i = 0; i < payloadLength; i++) { frame_buffer[frame_buffer_size] = unmasked_payload[i] ^ mask_key[i % sizeof(uint32_t)]; frame_buffer_size += 1; } @@ -1402,6 +1295,7 @@ - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode; } } + // SRFastLog(@"%@ Got stream event %d", aStream, eventCode); dispatch_async(_workQueue, ^{ switch (eventCode) { case NSStreamEventOpenCompleted: { @@ -1409,6 +1303,8 @@ - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode; if (self.readyState >= SR_CLOSING) { return; } + + assert(_readBuffer); if (self.readyState == SR_CONNECTING && aStream == _inputStream) { @@ -1443,11 +1339,11 @@ - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode; if (!_sentClose && !_failed) { _sentClose = YES; // If we get closed in this state it's probably not clean because we should be sending this when we send messages - [self _performDelegateBlock:^{ + dispatch_async(_callbackQueue, ^{ if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) { [self.delegate webSocket:self didCloseWithCode:0 reason:@"Stream end encountered" wasClean:NO]; } - }]; + }); } } @@ -1487,6 +1383,7 @@ - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode; break; } }); + } @end @@ -1500,62 +1397,20 @@ @implementation SRIOConsumer @synthesize readToCurrentFrame = _readToCurrentFrame; @synthesize unmaskBytes = _unmaskBytes; -- (void)setupWithScanner:(stream_scanner)scanner handler:(data_callback)handler bytesNeeded:(size_t)bytesNeeded readToCurrentFrame:(BOOL)readToCurrentFrame unmaskBytes:(BOOL)unmaskBytes; -{ - _scanner = [scanner copy]; - _handler = [handler copy]; - _bytesNeeded = bytesNeeded; - _readToCurrentFrame = readToCurrentFrame; - _unmaskBytes = unmaskBytes; - assert(_scanner || _bytesNeeded); -} - - -@end - - -@implementation SRIOConsumerPool { - NSUInteger _poolSize; - NSMutableArray *_bufferedConsumers; -} - -- (id)initWithBufferCapacity:(NSUInteger)poolSize; +- (id)initWithScanner:(stream_scanner)scanner handler:(data_callback)handler bytesNeeded:(size_t)bytesNeeded readToCurrentFrame:(BOOL)readToCurrentFrame unmaskBytes:(BOOL)unmaskBytes; { self = [super init]; if (self) { - _poolSize = poolSize; - _bufferedConsumers = [[NSMutableArray alloc] initWithCapacity:poolSize]; + _scanner = [scanner copy]; + _handler = [handler copy]; + _bytesNeeded = bytesNeeded; + _readToCurrentFrame = readToCurrentFrame; + _unmaskBytes = unmaskBytes; + assert(_scanner || _bytesNeeded); } return self; } -- (id)init -{ - return [self initWithBufferCapacity:8]; -} - -- (SRIOConsumer *)consumerWithScanner:(stream_scanner)scanner handler:(data_callback)handler bytesNeeded:(size_t)bytesNeeded readToCurrentFrame:(BOOL)readToCurrentFrame unmaskBytes:(BOOL)unmaskBytes; -{ - SRIOConsumer *consumer = nil; - if (_bufferedConsumers.count) { - consumer = [_bufferedConsumers lastObject]; - [_bufferedConsumers removeLastObject]; - } else { - consumer = [[SRIOConsumer alloc] init]; - } - - [consumer setupWithScanner:scanner handler:handler bytesNeeded:bytesNeeded readToCurrentFrame:readToCurrentFrame unmaskBytes:unmaskBytes]; - - return consumer; -} - -- (void)returnConsumer:(SRIOConsumer *)consumer; -{ - if (_bufferedConsumers.count < _poolSize) { - [_bufferedConsumers addObject:consumer]; - } -} - @end @@ -1604,6 +1459,7 @@ - (NSString *)SR_origin; @end static inline dispatch_queue_t log_queue() { + static dispatch_queue_t queue = 0; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -1632,11 +1488,13 @@ static inline void SRFastLog(NSString *format, ...) { #ifdef HAS_ICU static inline int32_t validate_dispatch_data_partial_string(NSData *data) { + const void * contents = [data bytes]; long size = [data length]; const uint8_t *str = (const uint8_t *)contents; + UChar32 codepoint = 1; int32_t offset = 0; int32_t lastOffset = 0; @@ -1655,6 +1513,7 @@ static inline int32_t validate_dispatch_data_partial_string(NSData *data) { U8_MASK_LEAD_BYTE(leadByte, U8_COUNT_TRAIL_BYTES(leadByte)); for (int i = lastOffset + 1; i < offset; i++) { + if (U8_IS_SINGLE(str[i]) || U8_IS_LEAD(str[i]) || !U8_IS_TRAIL(str[i])) { size = -1; } @@ -1691,67 +1550,4 @@ static inline int32_t validate_dispatch_data_partial_string(NSData *data) { #endif -static _SRRunLoopThread *networkThread = nil; -static NSRunLoop *networkRunLoop = nil; - -@implementation NSRunLoop (SRWebSocket) - -+ (NSRunLoop *)SR_networkRunLoop { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - networkThread = [[_SRRunLoopThread alloc] init]; - networkThread.name = @"com.squareup.SocketRocket.NetworkThread"; - [networkThread start]; - networkRunLoop = networkThread.runLoop; - }); - - return networkRunLoop; -} - -@end - - -@implementation _SRRunLoopThread { - dispatch_group_t _waitGroup; -} - -@synthesize runLoop = _runLoop; - -- (void)dealloc -{ - sr_dispatch_release(_waitGroup); -} - -- (id)init -{ - self = [super init]; - if (self) { - _waitGroup = dispatch_group_create(); - dispatch_group_enter(_waitGroup); - } - return self; -} - -- (void)main; -{ - @autoreleasepool { - _runLoop = [NSRunLoop currentRunLoop]; - dispatch_group_leave(_waitGroup); - - NSTimer *timer = [[NSTimer alloc] initWithFireDate:[NSDate distantFuture] interval:0.0 target:nil selector:nil userInfo:nil repeats:NO]; - [_runLoop addTimer:timer forMode:NSDefaultRunLoopMode]; - - while ([_runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]) { - - } - assert(NO); - } -} - -- (NSRunLoop *)runLoop; -{ - dispatch_group_wait(_waitGroup, DISPATCH_TIME_FOREVER); - return _runLoop; -} -@end diff --git a/vendor/Pods/SocketRocket/SocketRocket/base64.c b/vendor/Pods/SocketRocket/SocketRocket/base64.c index 1d76d16..7647385 100644 --- a/vendor/Pods/SocketRocket/SocketRocket/base64.c +++ b/vendor/Pods/SocketRocket/SocketRocket/base64.c @@ -311,4 +311,4 @@ b64_pton(char const *src, u_char *target, size_t targsize) } #endif /* !defined(HAVE_B64_PTON) && !defined(HAVE___B64_PTON) */ -#endif +#endif \ No newline at end of file diff --git a/vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-Private.xcconfig b/vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-Private.xcconfig new file mode 100644 index 0000000..1fe7e4c --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-Private.xcconfig @@ -0,0 +1,5 @@ +#include "Pods-AFNetworking.xcconfig" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Build" "${PODS_ROOT}/Headers/Build/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MASShortcut" "${PODS_ROOT}/Headers/Public/SocketRocket" +OTHER_LDFLAGS = ${PODS_AFNETWORKING_OTHER_LDFLAGS} -ObjC +PODS_ROOT = ${SRCROOT} \ No newline at end of file diff --git a/vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-dummy.m b/vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-dummy.m new file mode 100644 index 0000000..c50a8c6 --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_AFNetworking : NSObject +@end +@implementation PodsDummy_Pods_AFNetworking +@end diff --git a/vendor/Pods/Pods-SocketRocket-prefix.pch b/vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-prefix.pch similarity index 100% rename from vendor/Pods/Pods-SocketRocket-prefix.pch rename to vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-prefix.pch diff --git a/vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking.xcconfig b/vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking.xcconfig new file mode 100644 index 0000000..2011017 --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking.xcconfig @@ -0,0 +1 @@ +PODS_AFNETWORKING_OTHER_LDFLAGS = -framework "CoreServices" -framework "Security" -framework "SystemConfiguration" \ No newline at end of file diff --git a/vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut-Private.xcconfig b/vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut-Private.xcconfig new file mode 100644 index 0000000..ede20af --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut-Private.xcconfig @@ -0,0 +1,5 @@ +#include "Pods-MASShortcut.xcconfig" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Build" "${PODS_ROOT}/Headers/Build/MASShortcut" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MASShortcut" "${PODS_ROOT}/Headers/Public/SocketRocket" +OTHER_LDFLAGS = ${PODS_MASSHORTCUT_OTHER_LDFLAGS} -ObjC +PODS_ROOT = ${SRCROOT} \ No newline at end of file diff --git a/vendor/Pods/Pods-MASShortcut-dummy.m b/vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut-dummy.m similarity index 100% rename from vendor/Pods/Pods-MASShortcut-dummy.m rename to vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut-dummy.m diff --git a/vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut-prefix.pch b/vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut-prefix.pch new file mode 100644 index 0000000..2e9257c --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut-prefix.pch @@ -0,0 +1,5 @@ +#ifdef __OBJC__ +#import +#endif + +#import "Pods-environment.h" diff --git a/vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut.xcconfig b/vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut.xcconfig new file mode 100644 index 0000000..ae05631 --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods-MASShortcut/Pods-MASShortcut.xcconfig @@ -0,0 +1 @@ +PODS_MASSHORTCUT_OTHER_LDFLAGS = -framework "AppKit" -framework "Carbon" \ No newline at end of file diff --git a/vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket-Private.xcconfig b/vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket-Private.xcconfig new file mode 100644 index 0000000..281b791 --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket-Private.xcconfig @@ -0,0 +1,5 @@ +#include "Pods-SocketRocket.xcconfig" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Build" "${PODS_ROOT}/Headers/Build/SocketRocket" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MASShortcut" "${PODS_ROOT}/Headers/Public/SocketRocket" +OTHER_LDFLAGS = ${PODS_SOCKETROCKET_OTHER_LDFLAGS} -ObjC +PODS_ROOT = ${SRCROOT} \ No newline at end of file diff --git a/vendor/Pods/Pods-SocketRocket-dummy.m b/vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket-dummy.m similarity index 100% rename from vendor/Pods/Pods-SocketRocket-dummy.m rename to vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket-dummy.m diff --git a/vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket-prefix.pch b/vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket-prefix.pch new file mode 100644 index 0000000..2e9257c --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket-prefix.pch @@ -0,0 +1,5 @@ +#ifdef __OBJC__ +#import +#endif + +#import "Pods-environment.h" diff --git a/vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket.xcconfig b/vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket.xcconfig new file mode 100644 index 0000000..b2f49ac --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods-SocketRocket/Pods-SocketRocket.xcconfig @@ -0,0 +1 @@ +PODS_SOCKETROCKET_OTHER_LDFLAGS = -l"icucore" -framework "CoreServices" -framework "Security" \ No newline at end of file diff --git a/vendor/Pods/Pods-acknowledgements.markdown b/vendor/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown similarity index 65% rename from vendor/Pods/Pods-acknowledgements.markdown rename to vendor/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown index c6829ce..78f6bc2 100644 --- a/vendor/Pods/Pods-acknowledgements.markdown +++ b/vendor/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown @@ -1,6 +1,29 @@ # Acknowledgements This application makes use of the following third party libraries: +## AFNetworking + +Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + ## MASShortcut Copyright (c) 2012-2013, Vadim Shpakovski diff --git a/vendor/Pods/Pods-acknowledgements.plist b/vendor/Pods/Target Support Files/Pods/Pods-acknowledgements.plist similarity index 70% rename from vendor/Pods/Pods-acknowledgements.plist rename to vendor/Pods/Target Support Files/Pods/Pods-acknowledgements.plist index 06f2b35..3d08721 100644 --- a/vendor/Pods/Pods-acknowledgements.plist +++ b/vendor/Pods/Target Support Files/Pods/Pods-acknowledgements.plist @@ -12,6 +12,33 @@ Type PSGroupSpecifier + + FooterText + Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + Title + AFNetworking + Type + PSGroupSpecifier + FooterText Copyright (c) 2012-2013, Vadim Shpakovski diff --git a/vendor/Pods/Pods-dummy.m b/vendor/Pods/Target Support Files/Pods/Pods-dummy.m similarity index 100% rename from vendor/Pods/Pods-dummy.m rename to vendor/Pods/Target Support Files/Pods/Pods-dummy.m diff --git a/vendor/Pods/Target Support Files/Pods/Pods-environment.h b/vendor/Pods/Target Support Files/Pods/Pods-environment.h new file mode 100644 index 0000000..432df3a --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods/Pods-environment.h @@ -0,0 +1,8 @@ + +// To check if a library is compiled with CocoaPods you +// can use the `COCOAPODS` macro definition which is +// defined in the xcconfigs so it is available in +// headers also when they are imported in the client +// project. + + diff --git a/vendor/Pods/Pods-resources.sh b/vendor/Pods/Target Support Files/Pods/Pods-resources.sh similarity index 85% rename from vendor/Pods/Pods-resources.sh rename to vendor/Pods/Target Support Files/Pods/Pods-resources.sh index 39c2549..e149064 100755 --- a/vendor/Pods/Pods-resources.sh +++ b/vendor/Pods/Target Support Files/Pods/Pods-resources.sh @@ -1,6 +1,8 @@ #!/bin/sh set -e +mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt > "$RESOURCES_TO_COPY" @@ -29,6 +31,10 @@ install_resource() echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" ;; + *.xcmappingmodel) + echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" + xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" + ;; *.xcassets) ;; /*) @@ -48,9 +54,9 @@ if [[ "${ACTION}" == "install" ]]; then fi rm -f "$RESOURCES_TO_COPY" -if [[ -n "${WRAPPER_EXTENSION}" ]] && [ `xcrun --find actool` ] && [ `find . -name '*.xcassets' | wc -l` -ne 0 ] +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ `find . -name '*.xcassets' | wc -l` -ne 0 ] then - case "${TARGETED_DEVICE_FAMILY}" in + case "${TARGETED_DEVICE_FAMILY}" in 1,2) TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" ;; @@ -62,7 +68,7 @@ then ;; *) TARGET_DEVICE_ARGS="--target-device mac" - ;; - esac + ;; + esac find "${PWD}" -name "*.xcassets" -print0 | xargs -0 actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" fi diff --git a/vendor/Pods/Target Support Files/Pods/Pods.debug.xcconfig b/vendor/Pods/Target Support Files/Pods/Pods.debug.xcconfig new file mode 100644 index 0000000..17cd83c --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods/Pods.debug.xcconfig @@ -0,0 +1,6 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MASShortcut" "${PODS_ROOT}/Headers/Public/SocketRocket" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/MASShortcut" -isystem "${PODS_ROOT}/Headers/Public/SocketRocket" +OTHER_LDFLAGS = -ObjC -l"Pods-AFNetworking" -l"Pods-MASShortcut" -l"Pods-SocketRocket" -l"icucore" -framework "AppKit" -framework "Carbon" -framework "CoreServices" -framework "Security" -framework "SystemConfiguration" +OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) +PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/vendor/Pods/Target Support Files/Pods/Pods.release.xcconfig b/vendor/Pods/Target Support Files/Pods/Pods.release.xcconfig new file mode 100644 index 0000000..17cd83c --- /dev/null +++ b/vendor/Pods/Target Support Files/Pods/Pods.release.xcconfig @@ -0,0 +1,6 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MASShortcut" "${PODS_ROOT}/Headers/Public/SocketRocket" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/MASShortcut" -isystem "${PODS_ROOT}/Headers/Public/SocketRocket" +OTHER_LDFLAGS = -ObjC -l"Pods-AFNetworking" -l"Pods-MASShortcut" -l"Pods-SocketRocket" -l"icucore" -framework "AppKit" -framework "Carbon" -framework "CoreServices" -framework "Security" -framework "SystemConfiguration" +OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) +PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/vendor/Pods/build-MacOSX/Pods.bridgesupport b/vendor/Pods/build-MacOSX/Pods.bridgesupport index 6719ba9..99d701c 100644 --- a/vendor/Pods/build-MacOSX/Pods.bridgesupport +++ b/vendor/Pods/build-MacOSX/Pods.bridgesupport @@ -1,10 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + @@ -27,6 +67,22 @@ + + + + + + + + + + + + + + + + @@ -40,38 +96,1223 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - @@ -87,59 +1328,101 @@ - - - + + + + + + + + + + + + + + - - + + + + + + + + + + + + + - - + + - + + + + + + + + + + + + + - + + + + + + - - + - - + + - - - + + + + - - - + + + + + - - - - + + + + - + + - - + + + + + - - - @@ -149,14 +1432,20 @@ - - - - + + + + + + + + + + @@ -165,6 +1454,10 @@ + + + + @@ -176,9 +1469,16 @@ + + + + + + + @@ -188,6 +1488,9 @@ + + + @@ -204,6 +1507,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -226,11 +1585,6 @@ - - - - - @@ -275,11 +1629,6 @@ - - - - - @@ -288,23 +1637,72 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + - - - + + + + + + - - + + + + - + + + + + + + + + + + + + + + + + diff --git a/vendor/Pods/build-MacOSX/libPods-AFNetworking.a b/vendor/Pods/build-MacOSX/libPods-AFNetworking.a new file mode 100644 index 0000000..c92d889 Binary files /dev/null and b/vendor/Pods/build-MacOSX/libPods-AFNetworking.a differ diff --git a/vendor/Pods/build-MacOSX/libPods-MASShortcut.a b/vendor/Pods/build-MacOSX/libPods-MASShortcut.a new file mode 100644 index 0000000..395ff1e Binary files /dev/null and b/vendor/Pods/build-MacOSX/libPods-MASShortcut.a differ diff --git a/vendor/Pods/build-MacOSX/libPods-SocketRocket.a b/vendor/Pods/build-MacOSX/libPods-SocketRocket.a new file mode 100644 index 0000000..4724d6f Binary files /dev/null and b/vendor/Pods/build-MacOSX/libPods-SocketRocket.a differ diff --git a/vendor/Pods/build-MacOSX/libPods.a b/vendor/Pods/build-MacOSX/libPods.a deleted file mode 100644 index eeae414..0000000 Binary files a/vendor/Pods/build-MacOSX/libPods.a and /dev/null differ