motion-yapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +63 -0
- data/README.md +16 -0
- data/Rakefile +20 -0
- data/app/app_delegate.rb +5 -0
- data/lib/yapper.rb +30 -0
- data/lib/yapper/attachment.rb +48 -0
- data/lib/yapper/bson.rb +20 -0
- data/lib/yapper/config.rb +18 -0
- data/lib/yapper/db.rb +151 -0
- data/lib/yapper/document.rb +54 -0
- data/lib/yapper/document/attachment.rb +26 -0
- data/lib/yapper/document/callbacks.rb +86 -0
- data/lib/yapper/document/persistance.rb +171 -0
- data/lib/yapper/document/relation.rb +84 -0
- data/lib/yapper/document/selection.rb +100 -0
- data/lib/yapper/extensions.rb +80 -0
- data/lib/yapper/log.rb +5 -0
- data/lib/yapper/sync.rb +134 -0
- data/lib/yapper/sync/data.rb +12 -0
- data/lib/yapper/sync/event.rb +194 -0
- data/lib/yapper/sync/queue.rb +164 -0
- data/lib/yapper/timestamps.rb +16 -0
- data/lib/yapper/version.rb +3 -0
- data/lib/yapper/yapper.rb +2 -0
- data/spec/helpers/time_helper.rb +3 -0
- data/spec/integration/all_spec.rb +40 -0
- data/spec/integration/callback_spec.rb +87 -0
- data/spec/integration/db_spec.rb +40 -0
- data/spec/integration/find_spec.rb +51 -0
- data/spec/integration/persistance_spec.rb +118 -0
- data/spec/integration/relation_spec.rb +174 -0
- data/spec/integration/sync_spec.rb +42 -0
- data/spec/integration/timestamps_spec.rb +34 -0
- data/spec/integration/types_spec.rb +23 -0
- data/spec/integration/when_spec.rb +29 -0
- data/spec/integration/where_spec.rb +132 -0
- data/vendor/Podfile.lock +24 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +1396 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +327 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +321 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +150 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +157 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +143 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +848 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +167 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +191 -0
- data/vendor/Pods/AFNetworking/LICENSE +19 -0
- data/vendor/Pods/AFNetworking/README.md +208 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/CocoaLumberjack/LICENSE.txt +18 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1353 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +601 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +1083 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1479 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +7 -0
- data/vendor/Pods/CocoaLumberjack/README.markdown +37 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/Headers/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Headers/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/Headers/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/Headers/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +17 -0
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-environment.h +38 -0
- data/vendor/Pods/Manifest.lock +24 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +39 -0
- data/vendor/Pods/NSData+MD5Digest/README.md +11 -0
- data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-AFNetworking-dummy.m +5 -0
- data/vendor/Pods/Pods-AFNetworking-prefix.pch +17 -0
- data/vendor/Pods/Pods-AFNetworking.xcconfig +1 -0
- data/vendor/Pods/Pods-Acknowledgements.markdown +96 -0
- data/vendor/Pods/Pods-Acknowledgements.plist +142 -0
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
- data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
- data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-YapDatabase-dummy.m +5 -0
- data/vendor/Pods/Pods-YapDatabase-prefix.pch +5 -0
- data/vendor/Pods/Pods-YapDatabase.xcconfig +1 -0
- data/vendor/Pods/Pods-dummy.m +5 -0
- data/vendor/Pods/Pods-environment.h +38 -0
- data/vendor/Pods/Pods-resources.sh +68 -0
- data/vendor/Pods/Pods.bridgesupport +5096 -0
- data/vendor/Pods/Pods.xcconfig +5 -0
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +5536 -0
- data/vendor/Pods/Reachability/LICENCE.txt +24 -0
- data/vendor/Pods/Reachability/README.md +65 -0
- data/vendor/Pods/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Reachability/Reachability.m +527 -0
- data/vendor/Pods/YapDatabase/LICENSE.txt +18 -0
- data/vendor/Pods/YapDatabase/README.md +30 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +175 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +966 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +146 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +298 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +95 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +1352 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +46 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +180 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +149 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +184 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +1166 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +296 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +28 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +2494 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +1567 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +141 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +186 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +191 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +897 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +4505 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +90 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +453 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +48 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +83 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +26 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +121 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +74 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +603 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +20 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +194 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +96 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +82 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +2022 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +3874 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +5282 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +13 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -0
- data/yapper.gemspec +24 -0
- metadata +458 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2011-2013, Tony Million.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
15
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
16
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
17
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
18
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
19
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
20
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
21
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
22
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
23
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
24
|
+
POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Reachability
|
2
|
+
|
3
|
+
This is a drop-in replacement for Apple's `Reachability` class. It is ARC-compatible, and it uses the new GCD methods to notify of network interface changes.
|
4
|
+
|
5
|
+
In addition to the standard `NSNotification`, it supports the use of blocks for when the network becomes reachable and unreachable.
|
6
|
+
|
7
|
+
Finally, you can specify whether a WWAN connection is considered "reachable".
|
8
|
+
|
9
|
+
## Requirements
|
10
|
+
|
11
|
+
Once you have added the `.h/m` files to your project, simply:
|
12
|
+
|
13
|
+
* Go to the `Project->TARGETS->Build Phases->Link Binary With Libraries`.
|
14
|
+
* Press the plus in the lower left of the list.
|
15
|
+
* Add `SystemConfiguration.framework`.
|
16
|
+
|
17
|
+
Boom, you're done.
|
18
|
+
|
19
|
+
## Examples
|
20
|
+
|
21
|
+
### Block Example
|
22
|
+
|
23
|
+
This sample uses blocks to notify when the interface state has changed. The blocks will be called on a **BACKGROUND THREAD**, so you need to dispatch UI updates onto the main thread.
|
24
|
+
|
25
|
+
// Allocate a reachability object
|
26
|
+
Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];
|
27
|
+
|
28
|
+
// Set the blocks
|
29
|
+
reach.reachableBlock = ^(Reachability*reach)
|
30
|
+
{
|
31
|
+
NSLog(@"REACHABLE!");
|
32
|
+
};
|
33
|
+
|
34
|
+
reach.unreachableBlock = ^(Reachability*reach)
|
35
|
+
{
|
36
|
+
NSLog(@"UNREACHABLE!");
|
37
|
+
};
|
38
|
+
|
39
|
+
// Start the notifier, which will cause the reachability object to retain itself!
|
40
|
+
[reach startNotifier];
|
41
|
+
|
42
|
+
### `NSNotification` Example
|
43
|
+
|
44
|
+
This sample will use `NSNotification`s to notify when the interface has changed. They will be delivered on the **MAIN THREAD**, so you *can* do UI updates from within the function.
|
45
|
+
|
46
|
+
In addition, it asks the `Reachability` object to consider the WWAN (3G/EDGE/CDMA) as a non-reachable connection (you might use this if you are writing a video streaming app, for example, to save the user's data plan).
|
47
|
+
|
48
|
+
// Allocate a reachability object
|
49
|
+
Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];
|
50
|
+
|
51
|
+
// Tell the reachability that we DON'T want to be reachable on 3G/EDGE/CDMA
|
52
|
+
reach.reachableOnWWAN = NO;
|
53
|
+
|
54
|
+
// Here we set up a NSNotification observer. The Reachability that caused the notification
|
55
|
+
// is passed in the object parameter
|
56
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
57
|
+
selector:@selector(reachabilityChanged:)
|
58
|
+
name:kReachabilityChangedNotification
|
59
|
+
object:nil];
|
60
|
+
|
61
|
+
[reach startNotifier]
|
62
|
+
|
63
|
+
## Tell the world
|
64
|
+
|
65
|
+
Head over to [Projects using Reachability](https://github.com/tonymillion/Reachability/wiki/Projects-using-Reachability) and add your project for "Maximum Wins!".
|
@@ -0,0 +1,109 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2011, Tony Million.
|
3
|
+
All rights reserved.
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
7
|
+
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
list of conditions and the following disclaimer.
|
10
|
+
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
13
|
+
and/or other materials provided with the distribution.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
19
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
+
POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
*/
|
27
|
+
|
28
|
+
#import <Foundation/Foundation.h>
|
29
|
+
#import <SystemConfiguration/SystemConfiguration.h>
|
30
|
+
|
31
|
+
#import <sys/socket.h>
|
32
|
+
#import <netinet/in.h>
|
33
|
+
#import <netinet6/in6.h>
|
34
|
+
#import <arpa/inet.h>
|
35
|
+
#import <ifaddrs.h>
|
36
|
+
#import <netdb.h>
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Does ARC support GCD objects?
|
40
|
+
* It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
|
41
|
+
*
|
42
|
+
* @see http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h
|
43
|
+
**/
|
44
|
+
#if OS_OBJECT_USE_OBJC
|
45
|
+
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
|
46
|
+
#else
|
47
|
+
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
|
48
|
+
#endif
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X.
|
52
|
+
*
|
53
|
+
* @see http://nshipster.com/ns_enum-ns_options/
|
54
|
+
**/
|
55
|
+
#ifndef NS_ENUM
|
56
|
+
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
|
57
|
+
#endif
|
58
|
+
|
59
|
+
extern NSString *const kReachabilityChangedNotification;
|
60
|
+
|
61
|
+
typedef NS_ENUM(NSInteger, NetworkStatus) {
|
62
|
+
// Apple NetworkStatus Compatible Names.
|
63
|
+
NotReachable = 0,
|
64
|
+
ReachableViaWiFi = 2,
|
65
|
+
ReachableViaWWAN = 1
|
66
|
+
};
|
67
|
+
|
68
|
+
@class Reachability;
|
69
|
+
|
70
|
+
typedef void (^NetworkReachable)(Reachability * reachability);
|
71
|
+
typedef void (^NetworkUnreachable)(Reachability * reachability);
|
72
|
+
|
73
|
+
@interface Reachability : NSObject
|
74
|
+
|
75
|
+
@property (nonatomic, copy) NetworkReachable reachableBlock;
|
76
|
+
@property (nonatomic, copy) NetworkUnreachable unreachableBlock;
|
77
|
+
|
78
|
+
|
79
|
+
@property (nonatomic, assign) BOOL reachableOnWWAN;
|
80
|
+
|
81
|
+
+(Reachability*)reachabilityWithHostname:(NSString*)hostname;
|
82
|
+
+(Reachability*)reachabilityForInternetConnection;
|
83
|
+
+(Reachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
|
84
|
+
+(Reachability*)reachabilityForLocalWiFi;
|
85
|
+
|
86
|
+
-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
|
87
|
+
|
88
|
+
-(BOOL)startNotifier;
|
89
|
+
-(void)stopNotifier;
|
90
|
+
|
91
|
+
-(BOOL)isReachable;
|
92
|
+
-(BOOL)isReachableViaWWAN;
|
93
|
+
-(BOOL)isReachableViaWiFi;
|
94
|
+
|
95
|
+
// WWAN may be available, but not active until a connection has been established.
|
96
|
+
// WiFi may require a connection for VPN on Demand.
|
97
|
+
-(BOOL)isConnectionRequired; // Identical DDG variant.
|
98
|
+
-(BOOL)connectionRequired; // Apple's routine.
|
99
|
+
// Dynamic, on demand connection?
|
100
|
+
-(BOOL)isConnectionOnDemand;
|
101
|
+
// Is user intervention required?
|
102
|
+
-(BOOL)isInterventionRequired;
|
103
|
+
|
104
|
+
-(NetworkStatus)currentReachabilityStatus;
|
105
|
+
-(SCNetworkReachabilityFlags)reachabilityFlags;
|
106
|
+
-(NSString*)currentReachabilityString;
|
107
|
+
-(NSString*)currentReachabilityFlags;
|
108
|
+
|
109
|
+
@end
|
@@ -0,0 +1,527 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2011, Tony Million.
|
3
|
+
All rights reserved.
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
7
|
+
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
list of conditions and the following disclaimer.
|
10
|
+
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
13
|
+
and/or other materials provided with the distribution.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
19
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
+
POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
*/
|
27
|
+
|
28
|
+
#import "Reachability.h"
|
29
|
+
|
30
|
+
|
31
|
+
NSString *const kReachabilityChangedNotification = @"kReachabilityChangedNotification";
|
32
|
+
|
33
|
+
@interface Reachability ()
|
34
|
+
|
35
|
+
@property (nonatomic, assign) SCNetworkReachabilityRef reachabilityRef;
|
36
|
+
|
37
|
+
|
38
|
+
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
39
|
+
@property (nonatomic, assign) dispatch_queue_t reachabilitySerialQueue;
|
40
|
+
#else
|
41
|
+
@property (nonatomic, strong) dispatch_queue_t reachabilitySerialQueue;
|
42
|
+
#endif
|
43
|
+
|
44
|
+
|
45
|
+
@property (nonatomic, strong) id reachabilityObject;
|
46
|
+
|
47
|
+
-(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags;
|
48
|
+
-(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags;
|
49
|
+
|
50
|
+
@end
|
51
|
+
|
52
|
+
static NSString *reachabilityFlags(SCNetworkReachabilityFlags flags)
|
53
|
+
{
|
54
|
+
return [NSString stringWithFormat:@"%c%c %c%c%c%c%c%c%c",
|
55
|
+
#if TARGET_OS_IPHONE
|
56
|
+
(flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
|
57
|
+
#else
|
58
|
+
'X',
|
59
|
+
#endif
|
60
|
+
(flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
|
61
|
+
(flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
|
62
|
+
(flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
|
63
|
+
(flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
|
64
|
+
(flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
|
65
|
+
(flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
|
66
|
+
(flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
|
67
|
+
(flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-'];
|
68
|
+
}
|
69
|
+
|
70
|
+
// Start listening for reachability notifications on the current run loop
|
71
|
+
static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
|
72
|
+
{
|
73
|
+
#pragma unused (target)
|
74
|
+
#if __has_feature(objc_arc)
|
75
|
+
Reachability *reachability = ((__bridge Reachability*)info);
|
76
|
+
#else
|
77
|
+
Reachability *reachability = ((Reachability*)info);
|
78
|
+
#endif
|
79
|
+
|
80
|
+
// We probably don't need an autoreleasepool here, as GCD docs state each queue has its own autorelease pool,
|
81
|
+
// but what the heck eh?
|
82
|
+
@autoreleasepool
|
83
|
+
{
|
84
|
+
[reachability reachabilityChanged:flags];
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
@implementation Reachability
|
90
|
+
|
91
|
+
@synthesize reachabilityRef;
|
92
|
+
@synthesize reachabilitySerialQueue;
|
93
|
+
|
94
|
+
@synthesize reachableOnWWAN;
|
95
|
+
|
96
|
+
@synthesize reachableBlock;
|
97
|
+
@synthesize unreachableBlock;
|
98
|
+
|
99
|
+
@synthesize reachabilityObject;
|
100
|
+
|
101
|
+
#pragma mark - Class Constructor Methods
|
102
|
+
|
103
|
+
+(Reachability*)reachabilityWithHostName:(NSString*)hostname
|
104
|
+
{
|
105
|
+
return [Reachability reachabilityWithHostname:hostname];
|
106
|
+
}
|
107
|
+
|
108
|
+
+(Reachability*)reachabilityWithHostname:(NSString*)hostname
|
109
|
+
{
|
110
|
+
SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]);
|
111
|
+
if (ref)
|
112
|
+
{
|
113
|
+
id reachability = [[self alloc] initWithReachabilityRef:ref];
|
114
|
+
|
115
|
+
#if __has_feature(objc_arc)
|
116
|
+
return reachability;
|
117
|
+
#else
|
118
|
+
return [reachability autorelease];
|
119
|
+
#endif
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
return nil;
|
124
|
+
}
|
125
|
+
|
126
|
+
+(Reachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress
|
127
|
+
{
|
128
|
+
SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
|
129
|
+
if (ref)
|
130
|
+
{
|
131
|
+
id reachability = [[self alloc] initWithReachabilityRef:ref];
|
132
|
+
|
133
|
+
#if __has_feature(objc_arc)
|
134
|
+
return reachability;
|
135
|
+
#else
|
136
|
+
return [reachability autorelease];
|
137
|
+
#endif
|
138
|
+
}
|
139
|
+
|
140
|
+
return nil;
|
141
|
+
}
|
142
|
+
|
143
|
+
+(Reachability *)reachabilityForInternetConnection
|
144
|
+
{
|
145
|
+
struct sockaddr_in zeroAddress;
|
146
|
+
bzero(&zeroAddress, sizeof(zeroAddress));
|
147
|
+
zeroAddress.sin_len = sizeof(zeroAddress);
|
148
|
+
zeroAddress.sin_family = AF_INET;
|
149
|
+
|
150
|
+
return [self reachabilityWithAddress:&zeroAddress];
|
151
|
+
}
|
152
|
+
|
153
|
+
+(Reachability*)reachabilityForLocalWiFi
|
154
|
+
{
|
155
|
+
struct sockaddr_in localWifiAddress;
|
156
|
+
bzero(&localWifiAddress, sizeof(localWifiAddress));
|
157
|
+
localWifiAddress.sin_len = sizeof(localWifiAddress);
|
158
|
+
localWifiAddress.sin_family = AF_INET;
|
159
|
+
// IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
|
160
|
+
localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
|
161
|
+
|
162
|
+
return [self reachabilityWithAddress:&localWifiAddress];
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
// Initialization methods
|
167
|
+
|
168
|
+
-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref
|
169
|
+
{
|
170
|
+
self = [super init];
|
171
|
+
if (self != nil)
|
172
|
+
{
|
173
|
+
self.reachableOnWWAN = YES;
|
174
|
+
self.reachabilityRef = ref;
|
175
|
+
}
|
176
|
+
|
177
|
+
return self;
|
178
|
+
}
|
179
|
+
|
180
|
+
-(void)dealloc
|
181
|
+
{
|
182
|
+
[self stopNotifier];
|
183
|
+
|
184
|
+
if(self.reachabilityRef)
|
185
|
+
{
|
186
|
+
CFRelease(self.reachabilityRef);
|
187
|
+
self.reachabilityRef = nil;
|
188
|
+
}
|
189
|
+
|
190
|
+
self.reachableBlock = nil;
|
191
|
+
self.unreachableBlock = nil;
|
192
|
+
|
193
|
+
#if !(__has_feature(objc_arc))
|
194
|
+
[super dealloc];
|
195
|
+
#endif
|
196
|
+
|
197
|
+
|
198
|
+
}
|
199
|
+
|
200
|
+
#pragma mark - Notifier Methods
|
201
|
+
|
202
|
+
// Notifier
|
203
|
+
// NOTE: This uses GCD to trigger the blocks - they *WILL NOT* be called on THE MAIN THREAD
|
204
|
+
// - In other words DO NOT DO ANY UI UPDATES IN THE BLOCKS.
|
205
|
+
// INSTEAD USE dispatch_async(dispatch_get_main_queue(), ^{UISTUFF}) (or dispatch_sync if you want)
|
206
|
+
|
207
|
+
-(BOOL)startNotifier
|
208
|
+
{
|
209
|
+
SCNetworkReachabilityContext context = { 0, NULL, NULL, NULL, NULL };
|
210
|
+
|
211
|
+
// this should do a retain on ourself, so as long as we're in notifier mode we shouldn't disappear out from under ourselves
|
212
|
+
// woah
|
213
|
+
self.reachabilityObject = self;
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
// First, we need to create a serial queue.
|
218
|
+
// We allocate this once for the lifetime of the notifier.
|
219
|
+
self.reachabilitySerialQueue = dispatch_queue_create("com.tonymillion.reachability", NULL);
|
220
|
+
if(!self.reachabilitySerialQueue)
|
221
|
+
{
|
222
|
+
return NO;
|
223
|
+
}
|
224
|
+
|
225
|
+
#if __has_feature(objc_arc)
|
226
|
+
context.info = (__bridge void *)self;
|
227
|
+
#else
|
228
|
+
context.info = (void *)self;
|
229
|
+
#endif
|
230
|
+
|
231
|
+
if (!SCNetworkReachabilitySetCallback(self.reachabilityRef, TMReachabilityCallback, &context))
|
232
|
+
{
|
233
|
+
#ifdef DEBUG
|
234
|
+
NSLog(@"SCNetworkReachabilitySetCallback() failed: %s", SCErrorString(SCError()));
|
235
|
+
#endif
|
236
|
+
|
237
|
+
// Clear out the dispatch queue
|
238
|
+
if(self.reachabilitySerialQueue)
|
239
|
+
{
|
240
|
+
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
241
|
+
dispatch_release(self.reachabilitySerialQueue);
|
242
|
+
#endif
|
243
|
+
self.reachabilitySerialQueue = nil;
|
244
|
+
}
|
245
|
+
|
246
|
+
self.reachabilityObject = nil;
|
247
|
+
|
248
|
+
return NO;
|
249
|
+
}
|
250
|
+
|
251
|
+
// Set it as our reachability queue, which will retain the queue
|
252
|
+
if(!SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, self.reachabilitySerialQueue))
|
253
|
+
{
|
254
|
+
#ifdef DEBUG
|
255
|
+
NSLog(@"SCNetworkReachabilitySetDispatchQueue() failed: %s", SCErrorString(SCError()));
|
256
|
+
#endif
|
257
|
+
|
258
|
+
// UH OH - FAILURE!
|
259
|
+
|
260
|
+
// First stop, any callbacks!
|
261
|
+
SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL);
|
262
|
+
|
263
|
+
// Then clear out the dispatch queue.
|
264
|
+
if(self.reachabilitySerialQueue)
|
265
|
+
{
|
266
|
+
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
267
|
+
dispatch_release(self.reachabilitySerialQueue);
|
268
|
+
#endif
|
269
|
+
self.reachabilitySerialQueue = nil;
|
270
|
+
}
|
271
|
+
|
272
|
+
self.reachabilityObject = nil;
|
273
|
+
|
274
|
+
return NO;
|
275
|
+
}
|
276
|
+
|
277
|
+
return YES;
|
278
|
+
}
|
279
|
+
|
280
|
+
-(void)stopNotifier
|
281
|
+
{
|
282
|
+
// First stop, any callbacks!
|
283
|
+
SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL);
|
284
|
+
|
285
|
+
// Unregister target from the GCD serial dispatch queue.
|
286
|
+
SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, NULL);
|
287
|
+
|
288
|
+
if(self.reachabilitySerialQueue)
|
289
|
+
{
|
290
|
+
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
291
|
+
dispatch_release(self.reachabilitySerialQueue);
|
292
|
+
#endif
|
293
|
+
self.reachabilitySerialQueue = nil;
|
294
|
+
}
|
295
|
+
|
296
|
+
self.reachabilityObject = nil;
|
297
|
+
}
|
298
|
+
|
299
|
+
#pragma mark - reachability tests
|
300
|
+
|
301
|
+
// This is for the case where you flick the airplane mode;
|
302
|
+
// you end up getting something like this:
|
303
|
+
//Reachability: WR ct-----
|
304
|
+
//Reachability: -- -------
|
305
|
+
//Reachability: WR ct-----
|
306
|
+
//Reachability: -- -------
|
307
|
+
// We treat this as 4 UNREACHABLE triggers - really apple should do better than this
|
308
|
+
|
309
|
+
#define testcase (kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsTransientConnection)
|
310
|
+
|
311
|
+
-(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags
|
312
|
+
{
|
313
|
+
BOOL connectionUP = YES;
|
314
|
+
|
315
|
+
if(!(flags & kSCNetworkReachabilityFlagsReachable))
|
316
|
+
connectionUP = NO;
|
317
|
+
|
318
|
+
if( (flags & testcase) == testcase )
|
319
|
+
connectionUP = NO;
|
320
|
+
|
321
|
+
#if TARGET_OS_IPHONE
|
322
|
+
if(flags & kSCNetworkReachabilityFlagsIsWWAN)
|
323
|
+
{
|
324
|
+
// We're on 3G.
|
325
|
+
if(!self.reachableOnWWAN)
|
326
|
+
{
|
327
|
+
// We don't want to connect when on 3G.
|
328
|
+
connectionUP = NO;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
#endif
|
332
|
+
|
333
|
+
return connectionUP;
|
334
|
+
}
|
335
|
+
|
336
|
+
-(BOOL)isReachable
|
337
|
+
{
|
338
|
+
SCNetworkReachabilityFlags flags;
|
339
|
+
|
340
|
+
if(!SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
|
341
|
+
return NO;
|
342
|
+
|
343
|
+
return [self isReachableWithFlags:flags];
|
344
|
+
}
|
345
|
+
|
346
|
+
-(BOOL)isReachableViaWWAN
|
347
|
+
{
|
348
|
+
#if TARGET_OS_IPHONE
|
349
|
+
|
350
|
+
SCNetworkReachabilityFlags flags = 0;
|
351
|
+
|
352
|
+
if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
|
353
|
+
{
|
354
|
+
// Check we're REACHABLE
|
355
|
+
if(flags & kSCNetworkReachabilityFlagsReachable)
|
356
|
+
{
|
357
|
+
// Now, check we're on WWAN
|
358
|
+
if(flags & kSCNetworkReachabilityFlagsIsWWAN)
|
359
|
+
{
|
360
|
+
return YES;
|
361
|
+
}
|
362
|
+
}
|
363
|
+
}
|
364
|
+
#endif
|
365
|
+
|
366
|
+
return NO;
|
367
|
+
}
|
368
|
+
|
369
|
+
-(BOOL)isReachableViaWiFi
|
370
|
+
{
|
371
|
+
SCNetworkReachabilityFlags flags = 0;
|
372
|
+
|
373
|
+
if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
|
374
|
+
{
|
375
|
+
// Check we're reachable
|
376
|
+
if((flags & kSCNetworkReachabilityFlagsReachable))
|
377
|
+
{
|
378
|
+
#if TARGET_OS_IPHONE
|
379
|
+
// Check we're NOT on WWAN
|
380
|
+
if((flags & kSCNetworkReachabilityFlagsIsWWAN))
|
381
|
+
{
|
382
|
+
return NO;
|
383
|
+
}
|
384
|
+
#endif
|
385
|
+
return YES;
|
386
|
+
}
|
387
|
+
}
|
388
|
+
|
389
|
+
return NO;
|
390
|
+
}
|
391
|
+
|
392
|
+
|
393
|
+
// WWAN may be available, but not active until a connection has been established.
|
394
|
+
// WiFi may require a connection for VPN on Demand.
|
395
|
+
-(BOOL)isConnectionRequired
|
396
|
+
{
|
397
|
+
return [self connectionRequired];
|
398
|
+
}
|
399
|
+
|
400
|
+
-(BOOL)connectionRequired
|
401
|
+
{
|
402
|
+
SCNetworkReachabilityFlags flags;
|
403
|
+
|
404
|
+
if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
|
405
|
+
{
|
406
|
+
return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
|
407
|
+
}
|
408
|
+
|
409
|
+
return NO;
|
410
|
+
}
|
411
|
+
|
412
|
+
// Dynamic, on demand connection?
|
413
|
+
-(BOOL)isConnectionOnDemand
|
414
|
+
{
|
415
|
+
SCNetworkReachabilityFlags flags;
|
416
|
+
|
417
|
+
if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
|
418
|
+
{
|
419
|
+
return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) &&
|
420
|
+
(flags & (kSCNetworkReachabilityFlagsConnectionOnTraffic | kSCNetworkReachabilityFlagsConnectionOnDemand)));
|
421
|
+
}
|
422
|
+
|
423
|
+
return NO;
|
424
|
+
}
|
425
|
+
|
426
|
+
// Is user intervention required?
|
427
|
+
-(BOOL)isInterventionRequired
|
428
|
+
{
|
429
|
+
SCNetworkReachabilityFlags flags;
|
430
|
+
|
431
|
+
if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
|
432
|
+
{
|
433
|
+
return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) &&
|
434
|
+
(flags & kSCNetworkReachabilityFlagsInterventionRequired));
|
435
|
+
}
|
436
|
+
|
437
|
+
return NO;
|
438
|
+
}
|
439
|
+
|
440
|
+
|
441
|
+
#pragma mark - reachability status stuff
|
442
|
+
|
443
|
+
-(NetworkStatus)currentReachabilityStatus
|
444
|
+
{
|
445
|
+
if([self isReachable])
|
446
|
+
{
|
447
|
+
if([self isReachableViaWiFi])
|
448
|
+
return ReachableViaWiFi;
|
449
|
+
|
450
|
+
#if TARGET_OS_IPHONE
|
451
|
+
return ReachableViaWWAN;
|
452
|
+
#endif
|
453
|
+
}
|
454
|
+
|
455
|
+
return NotReachable;
|
456
|
+
}
|
457
|
+
|
458
|
+
-(SCNetworkReachabilityFlags)reachabilityFlags
|
459
|
+
{
|
460
|
+
SCNetworkReachabilityFlags flags = 0;
|
461
|
+
|
462
|
+
if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
|
463
|
+
{
|
464
|
+
return flags;
|
465
|
+
}
|
466
|
+
|
467
|
+
return 0;
|
468
|
+
}
|
469
|
+
|
470
|
+
-(NSString*)currentReachabilityString
|
471
|
+
{
|
472
|
+
NetworkStatus temp = [self currentReachabilityStatus];
|
473
|
+
|
474
|
+
if(temp == reachableOnWWAN)
|
475
|
+
{
|
476
|
+
// Updated for the fact that we have CDMA phones now!
|
477
|
+
return NSLocalizedString(@"Cellular", @"");
|
478
|
+
}
|
479
|
+
if (temp == ReachableViaWiFi)
|
480
|
+
{
|
481
|
+
return NSLocalizedString(@"WiFi", @"");
|
482
|
+
}
|
483
|
+
|
484
|
+
return NSLocalizedString(@"No Connection", @"");
|
485
|
+
}
|
486
|
+
|
487
|
+
-(NSString*)currentReachabilityFlags
|
488
|
+
{
|
489
|
+
return reachabilityFlags([self reachabilityFlags]);
|
490
|
+
}
|
491
|
+
|
492
|
+
#pragma mark - Callback function calls this method
|
493
|
+
|
494
|
+
-(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags
|
495
|
+
{
|
496
|
+
if([self isReachableWithFlags:flags])
|
497
|
+
{
|
498
|
+
if(self.reachableBlock)
|
499
|
+
{
|
500
|
+
self.reachableBlock(self);
|
501
|
+
}
|
502
|
+
}
|
503
|
+
else
|
504
|
+
{
|
505
|
+
if(self.unreachableBlock)
|
506
|
+
{
|
507
|
+
self.unreachableBlock(self);
|
508
|
+
}
|
509
|
+
}
|
510
|
+
|
511
|
+
// this makes sure the change notification happens on the MAIN THREAD
|
512
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
513
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification
|
514
|
+
object:self];
|
515
|
+
});
|
516
|
+
}
|
517
|
+
|
518
|
+
#pragma mark - Debug Description
|
519
|
+
|
520
|
+
- (NSString *) description;
|
521
|
+
{
|
522
|
+
NSString *description = [NSString stringWithFormat:@"<%@: %#x>",
|
523
|
+
NSStringFromClass([self class]), (unsigned int) self];
|
524
|
+
return description;
|
525
|
+
}
|
526
|
+
|
527
|
+
@end
|