├── .gitignore ├── README.markdown ├── ZLIB-LICENSE ├── samples ├── Chat │ ├── Chat-Info.plist │ ├── Chat.xcodeproj │ │ └── project.pbxproj │ ├── ChatViewController.xib │ ├── Chat_Prefix.pch │ ├── Classes │ │ ├── ChatAppDelegate.h │ │ ├── ChatAppDelegate.m │ │ ├── ChatTextView.h │ │ ├── ChatTextView.m │ │ ├── ChatViewController.h │ │ └── ChatViewController.m │ ├── MainWindow.xib │ ├── main.m │ └── server.rb └── FakeLocation │ ├── Classes │ ├── FakeLocationAppDelegate.h │ ├── FakeLocationAppDelegate.m │ ├── FakeLocationViewController.h │ └── FakeLocationViewController.m │ ├── FakeLocation-Info.plist │ ├── FakeLocation.xcodeproj │ └── project.pbxproj │ ├── FakeLocationViewController.xib │ ├── FakeLocation_Prefix.pch │ ├── MainWindow.xib │ ├── blue_dot.png │ ├── main.m │ └── vienna_ring.waypoints └── src ├── Vendor └── AsyncSocket │ ├── AsyncSocket Documentation.html │ ├── AsyncSocket.h │ ├── AsyncSocket.m │ ├── AsyncUdpSocket.h │ ├── AsyncUdpSocket.m │ └── changes.txt ├── ZTFakeLocationManager.m ├── ZTWebSocket.m ├── Zimt.xcodeproj └── project.pbxproj ├── Zimt ├── ZTFakeLocationManager.h ├── ZTLog.h ├── ZTWebSocket.h └── Zimt.h └── Zimt_Prefix.pch /.gitignore: -------------------------------------------------------------------------------- 1 | # xcode noise 2 | build 3 | *.pbxuser 4 | *.mode1v3 5 | 6 | # osx noise 7 | .DS_Store 8 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | **Zimt is now out of date and no longer maintained**. 2 | 3 | For a more complete and up-to-date Objective-C websocket implementation, take a look at [SocketRocket](https://github.com/square/SocketRocket). 4 | 5 | iOS Simulator now supports simulating location, also obsoleting the `ZTFakeLocationManager`. 6 | 7 | So long, and thanks for all this fish! -------------------------------------------------------------------------------- /ZLIB-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 Esad Hajdarevic 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to lalter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source 20 | distribution. -------------------------------------------------------------------------------- /samples/Chat/Chat-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /samples/Chat/Chat.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 45; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1D3623260D0F684500981E51 /* ChatAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* ChatAppDelegate.m */; }; 11 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 12 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 13 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 14 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; 15 | 2899E5220DE3E06400AC0155 /* ChatViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E5210DE3E06400AC0155 /* ChatViewController.xib */; }; 16 | 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; }; 17 | 28D7ACF80DDB3853001CB0EB /* ChatViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* ChatViewController.m */; }; 18 | C76180C5112AA8F6008E0A1C /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C76180C4112AA8F6008E0A1C /* CFNetwork.framework */; }; 19 | C7717053112AA71400C30F8A /* libZimt.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C771704F112AA70000C30F8A /* libZimt.a */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | C771704E112AA70000C30F8A /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = C771704A112AA70000C30F8A /* Zimt.xcodeproj */; 26 | proxyType = 2; 27 | remoteGlobalIDString = D2AAC07E0554694100DB518D; 28 | remoteInfo = Zimt; 29 | }; 30 | C7717051112AA70B00C30F8A /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = C771704A112AA70000C30F8A /* Zimt.xcodeproj */; 33 | proxyType = 1; 34 | remoteGlobalIDString = D2AAC07D0554694100DB518D; 35 | remoteInfo = Zimt; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 41 | 1D3623240D0F684500981E51 /* ChatAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatAppDelegate.h; sourceTree = ""; }; 42 | 1D3623250D0F684500981E51 /* ChatAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatAppDelegate.m; sourceTree = ""; }; 43 | 1D6058910D05DD3D006BFB54 /* Chat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Chat.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 45 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 46 | 2899E5210DE3E06400AC0155 /* ChatViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ChatViewController.xib; sourceTree = ""; }; 47 | 28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; 48 | 28D7ACF60DDB3853001CB0EB /* ChatViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatViewController.h; sourceTree = ""; }; 49 | 28D7ACF70DDB3853001CB0EB /* ChatViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatViewController.m; sourceTree = ""; }; 50 | 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 51 | 32CA4F630368D1EE00C91783 /* Chat_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Chat_Prefix.pch; sourceTree = ""; }; 52 | 8D1107310486CEB800E47090 /* Chat-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Chat-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; 53 | C76180C4112AA8F6008E0A1C /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; 54 | C771704A112AA70000C30F8A /* Zimt.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Zimt.xcodeproj; path = ../../src/Zimt.xcodeproj; sourceTree = SOURCE_ROOT; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | C7717053112AA71400C30F8A /* libZimt.a in Frameworks */, 63 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 64 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 65 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, 66 | C76180C5112AA8F6008E0A1C /* CFNetwork.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | /* End PBXFrameworksBuildPhase section */ 71 | 72 | /* Begin PBXGroup section */ 73 | 080E96DDFE201D6D7F000001 /* Classes */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 1D3623240D0F684500981E51 /* ChatAppDelegate.h */, 77 | 1D3623250D0F684500981E51 /* ChatAppDelegate.m */, 78 | 28D7ACF60DDB3853001CB0EB /* ChatViewController.h */, 79 | 28D7ACF70DDB3853001CB0EB /* ChatViewController.m */, 80 | ); 81 | path = Classes; 82 | sourceTree = ""; 83 | }; 84 | 19C28FACFE9D520D11CA2CBB /* Products */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 1D6058910D05DD3D006BFB54 /* Chat.app */, 88 | ); 89 | name = Products; 90 | sourceTree = ""; 91 | }; 92 | 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | C771704A112AA70000C30F8A /* Zimt.xcodeproj */, 96 | 080E96DDFE201D6D7F000001 /* Classes */, 97 | 29B97315FDCFA39411CA2CEA /* Other Sources */, 98 | 29B97317FDCFA39411CA2CEA /* Resources-iPhone */, 99 | 29B97323FDCFA39411CA2CEA /* Frameworks */, 100 | 19C28FACFE9D520D11CA2CBB /* Products */, 101 | ); 102 | name = CustomTemplate; 103 | sourceTree = ""; 104 | }; 105 | 29B97315FDCFA39411CA2CEA /* Other Sources */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 32CA4F630368D1EE00C91783 /* Chat_Prefix.pch */, 109 | 29B97316FDCFA39411CA2CEA /* main.m */, 110 | ); 111 | name = "Other Sources"; 112 | sourceTree = ""; 113 | }; 114 | 29B97317FDCFA39411CA2CEA /* Resources-iPhone */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 2899E5210DE3E06400AC0155 /* ChatViewController.xib */, 118 | 28AD733E0D9D9553002E5188 /* MainWindow.xib */, 119 | 8D1107310486CEB800E47090 /* Chat-Info.plist */, 120 | ); 121 | name = "Resources-iPhone"; 122 | sourceTree = ""; 123 | }; 124 | 29B97323FDCFA39411CA2CEA /* Frameworks */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 128 | 1D30AB110D05D00D00671497 /* Foundation.framework */, 129 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */, 130 | C76180C4112AA8F6008E0A1C /* CFNetwork.framework */, 131 | ); 132 | name = Frameworks; 133 | sourceTree = ""; 134 | }; 135 | C771704B112AA70000C30F8A /* Products */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | C771704F112AA70000C30F8A /* libZimt.a */, 139 | ); 140 | name = Products; 141 | sourceTree = ""; 142 | }; 143 | /* End PBXGroup section */ 144 | 145 | /* Begin PBXNativeTarget section */ 146 | 1D6058900D05DD3D006BFB54 /* Chat */ = { 147 | isa = PBXNativeTarget; 148 | buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Chat" */; 149 | buildPhases = ( 150 | 1D60588D0D05DD3D006BFB54 /* Resources */, 151 | 1D60588E0D05DD3D006BFB54 /* Sources */, 152 | 1D60588F0D05DD3D006BFB54 /* Frameworks */, 153 | ); 154 | buildRules = ( 155 | ); 156 | dependencies = ( 157 | C7717052112AA70B00C30F8A /* PBXTargetDependency */, 158 | ); 159 | name = Chat; 160 | productName = Chat; 161 | productReference = 1D6058910D05DD3D006BFB54 /* Chat.app */; 162 | productType = "com.apple.product-type.application"; 163 | }; 164 | /* End PBXNativeTarget section */ 165 | 166 | /* Begin PBXProject section */ 167 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 168 | isa = PBXProject; 169 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Chat" */; 170 | compatibilityVersion = "Xcode 3.1"; 171 | hasScannedForEncodings = 1; 172 | mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; 173 | projectDirPath = ""; 174 | projectReferences = ( 175 | { 176 | ProductGroup = C771704B112AA70000C30F8A /* Products */; 177 | ProjectRef = C771704A112AA70000C30F8A /* Zimt.xcodeproj */; 178 | }, 179 | ); 180 | projectRoot = ""; 181 | targets = ( 182 | 1D6058900D05DD3D006BFB54 /* Chat */, 183 | ); 184 | }; 185 | /* End PBXProject section */ 186 | 187 | /* Begin PBXReferenceProxy section */ 188 | C771704F112AA70000C30F8A /* libZimt.a */ = { 189 | isa = PBXReferenceProxy; 190 | fileType = archive.ar; 191 | path = libZimt.a; 192 | remoteRef = C771704E112AA70000C30F8A /* PBXContainerItemProxy */; 193 | sourceTree = BUILT_PRODUCTS_DIR; 194 | }; 195 | /* End PBXReferenceProxy section */ 196 | 197 | /* Begin PBXResourcesBuildPhase section */ 198 | 1D60588D0D05DD3D006BFB54 /* Resources */ = { 199 | isa = PBXResourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */, 203 | 2899E5220DE3E06400AC0155 /* ChatViewController.xib in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXResourcesBuildPhase section */ 208 | 209 | /* Begin PBXSourcesBuildPhase section */ 210 | 1D60588E0D05DD3D006BFB54 /* Sources */ = { 211 | isa = PBXSourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */, 215 | 1D3623260D0F684500981E51 /* ChatAppDelegate.m in Sources */, 216 | 28D7ACF80DDB3853001CB0EB /* ChatViewController.m in Sources */, 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | /* End PBXSourcesBuildPhase section */ 221 | 222 | /* Begin PBXTargetDependency section */ 223 | C7717052112AA70B00C30F8A /* PBXTargetDependency */ = { 224 | isa = PBXTargetDependency; 225 | name = Zimt; 226 | targetProxy = C7717051112AA70B00C30F8A /* PBXContainerItemProxy */; 227 | }; 228 | /* End PBXTargetDependency section */ 229 | 230 | /* Begin XCBuildConfiguration section */ 231 | 1D6058940D05DD3E006BFB54 /* Debug */ = { 232 | isa = XCBuildConfiguration; 233 | buildSettings = { 234 | ALWAYS_SEARCH_USER_PATHS = NO; 235 | COPY_PHASE_STRIP = NO; 236 | GCC_DYNAMIC_NO_PIC = NO; 237 | GCC_OPTIMIZATION_LEVEL = 0; 238 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 239 | GCC_PREFIX_HEADER = Chat_Prefix.pch; 240 | INFOPLIST_FILE = "Chat-Info.plist"; 241 | PRODUCT_NAME = Chat; 242 | }; 243 | name = Debug; 244 | }; 245 | 1D6058950D05DD3E006BFB54 /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | ALWAYS_SEARCH_USER_PATHS = NO; 249 | COPY_PHASE_STRIP = YES; 250 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 251 | GCC_PREFIX_HEADER = Chat_Prefix.pch; 252 | INFOPLIST_FILE = "Chat-Info.plist"; 253 | PRODUCT_NAME = Chat; 254 | VALIDATE_PRODUCT = YES; 255 | }; 256 | name = Release; 257 | }; 258 | C01FCF4F08A954540054247B /* Debug */ = { 259 | isa = XCBuildConfiguration; 260 | buildSettings = { 261 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | GCC_C_LANGUAGE_STANDARD = c99; 264 | GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; 265 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 266 | GCC_WARN_UNUSED_VARIABLE = YES; 267 | PREBINDING = NO; 268 | SDKROOT = iphoneos3.0; 269 | USER_HEADER_SEARCH_PATHS = "../../src/**"; 270 | }; 271 | name = Debug; 272 | }; 273 | C01FCF5008A954540054247B /* Release */ = { 274 | isa = XCBuildConfiguration; 275 | buildSettings = { 276 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 277 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 278 | GCC_C_LANGUAGE_STANDARD = c99; 279 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 280 | GCC_WARN_UNUSED_VARIABLE = YES; 281 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 282 | PREBINDING = NO; 283 | SDKROOT = iphoneos3.2; 284 | USER_HEADER_SEARCH_PATHS = "../../src/**"; 285 | }; 286 | name = Release; 287 | }; 288 | /* End XCBuildConfiguration section */ 289 | 290 | /* Begin XCConfigurationList section */ 291 | 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Chat" */ = { 292 | isa = XCConfigurationList; 293 | buildConfigurations = ( 294 | 1D6058940D05DD3E006BFB54 /* Debug */, 295 | 1D6058950D05DD3E006BFB54 /* Release */, 296 | ); 297 | defaultConfigurationIsVisible = 0; 298 | defaultConfigurationName = Release; 299 | }; 300 | C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Chat" */ = { 301 | isa = XCConfigurationList; 302 | buildConfigurations = ( 303 | C01FCF4F08A954540054247B /* Debug */, 304 | C01FCF5008A954540054247B /* Release */, 305 | ); 306 | defaultConfigurationIsVisible = 0; 307 | defaultConfigurationName = Release; 308 | }; 309 | /* End XCConfigurationList section */ 310 | }; 311 | rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; 312 | } 313 | -------------------------------------------------------------------------------- /samples/Chat/ChatViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 768 5 | 10C540 6 | 760 7 | 1038.25 8 | 458.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 82 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | 42 | 274 43 | 44 | YES 45 | 46 | 47 | 292 48 | {{5, 210}, {284, 31}} 49 | 50 | NO 51 | YES 52 | IBCocoaTouchFramework 53 | 0 54 | 55 | 3 56 | 57 | 3 58 | MAA 59 | 60 | 2 61 | 62 | 63 | YES 64 | 17 65 | 66 | IBCocoaTouchFramework 67 | 68 | 69 | 70 | 71 | 292 72 | {320, 207} 73 | 74 | 75 | 1 76 | MSAxIDEAA 77 | 78 | YES 79 | IBCocoaTouchFramework 80 | NO 81 | NO 82 | NO 83 | NO 84 | NO 85 | 86 | 87 | Helvetica 88 | 11 89 | 16 90 | 91 | 92 | 2 93 | IBCocoaTouchFramework 94 | 95 | 96 | 97 | 98 | -2147483356 99 | {{295, 215}, {20, 20}} 100 | 101 | NO 102 | IBCocoaTouchFramework 103 | 104 | 105 | 106 | -2147483356 107 | {{208, 4}, {107, 30}} 108 | 109 | NO 110 | IBCocoaTouchFramework 111 | 0 112 | 0 113 | 114 | 1 115 | Re-connect 116 | 117 | 3 118 | MQA 119 | 120 | 121 | 1 122 | MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA 123 | 124 | 125 | 3 126 | MC41AA 127 | 128 | 129 | 130 | {320, 460} 131 | 132 | 133 | 1 134 | MC40OTgwMzkyMTU4IDAuNDk4MDM5MjE1OCAwLjQ5ODAzOTIxNTgAA 135 | 136 | NO 137 | 138 | IBCocoaTouchFramework 139 | 140 | 141 | 142 | 143 | YES 144 | 145 | 146 | view 147 | 148 | 149 | 150 | 7 151 | 152 | 153 | 154 | textField 155 | 156 | 157 | 158 | 18 159 | 160 | 161 | 162 | delegate 163 | 164 | 165 | 166 | 19 167 | 168 | 169 | 170 | textView 171 | 172 | 173 | 174 | 21 175 | 176 | 177 | 178 | activityIndicator 179 | 180 | 181 | 182 | 25 183 | 184 | 185 | 186 | reconnectButton 187 | 188 | 189 | 190 | 28 191 | 192 | 193 | 194 | reconnect: 195 | 196 | 197 | 7 198 | 199 | 29 200 | 201 | 202 | 203 | 204 | YES 205 | 206 | 0 207 | 208 | 209 | 210 | 211 | 212 | -1 213 | 214 | 215 | File's Owner 216 | 217 | 218 | -2 219 | 220 | 221 | 222 | 223 | 6 224 | 225 | 226 | YES 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 16 236 | 237 | 238 | 239 | 240 | 20 241 | 242 | 243 | 244 | 245 | 24 246 | 247 | 248 | 249 | 250 | 27 251 | 252 | 253 | 254 | 255 | 256 | 257 | YES 258 | 259 | YES 260 | -1.CustomClassName 261 | -2.CustomClassName 262 | 16.IBPluginDependency 263 | 20.IBPluginDependency 264 | 24.IBPluginDependency 265 | 27.IBPluginDependency 266 | 6.IBEditorWindowLastContentRect 267 | 6.IBPluginDependency 268 | 269 | 270 | YES 271 | ChatViewController 272 | UIResponder 273 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 274 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 275 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 276 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 277 | {{424, 224}, {320, 480}} 278 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 279 | 280 | 281 | 282 | YES 283 | 284 | 285 | YES 286 | 287 | 288 | 289 | 290 | YES 291 | 292 | 293 | YES 294 | 295 | 296 | 297 | 29 298 | 299 | 300 | 301 | YES 302 | 303 | ChatViewController 304 | UIViewController 305 | 306 | reconnect: 307 | id 308 | 309 | 310 | YES 311 | 312 | YES 313 | activityIndicator 314 | reconnectButton 315 | textField 316 | textView 317 | 318 | 319 | YES 320 | UIActivityIndicatorView 321 | UIButton 322 | UITextField 323 | UITextView 324 | 325 | 326 | 327 | IBProjectSource 328 | Classes/ChatViewController.h 329 | 330 | 331 | 332 | 333 | YES 334 | 335 | NSObject 336 | 337 | IBFrameworkSource 338 | Foundation.framework/Headers/NSError.h 339 | 340 | 341 | 342 | NSObject 343 | 344 | IBFrameworkSource 345 | Foundation.framework/Headers/NSFileManager.h 346 | 347 | 348 | 349 | NSObject 350 | 351 | IBFrameworkSource 352 | Foundation.framework/Headers/NSKeyValueCoding.h 353 | 354 | 355 | 356 | NSObject 357 | 358 | IBFrameworkSource 359 | Foundation.framework/Headers/NSKeyValueObserving.h 360 | 361 | 362 | 363 | NSObject 364 | 365 | IBFrameworkSource 366 | Foundation.framework/Headers/NSKeyedArchiver.h 367 | 368 | 369 | 370 | NSObject 371 | 372 | IBFrameworkSource 373 | Foundation.framework/Headers/NSNetServices.h 374 | 375 | 376 | 377 | NSObject 378 | 379 | IBFrameworkSource 380 | Foundation.framework/Headers/NSObject.h 381 | 382 | 383 | 384 | NSObject 385 | 386 | IBFrameworkSource 387 | Foundation.framework/Headers/NSPort.h 388 | 389 | 390 | 391 | NSObject 392 | 393 | IBFrameworkSource 394 | Foundation.framework/Headers/NSRunLoop.h 395 | 396 | 397 | 398 | NSObject 399 | 400 | IBFrameworkSource 401 | Foundation.framework/Headers/NSStream.h 402 | 403 | 404 | 405 | NSObject 406 | 407 | IBFrameworkSource 408 | Foundation.framework/Headers/NSThread.h 409 | 410 | 411 | 412 | NSObject 413 | 414 | IBFrameworkSource 415 | Foundation.framework/Headers/NSURL.h 416 | 417 | 418 | 419 | NSObject 420 | 421 | IBFrameworkSource 422 | Foundation.framework/Headers/NSURLConnection.h 423 | 424 | 425 | 426 | NSObject 427 | 428 | IBFrameworkSource 429 | Foundation.framework/Headers/NSXMLParser.h 430 | 431 | 432 | 433 | NSObject 434 | 435 | IBFrameworkSource 436 | UIKit.framework/Headers/UIAccessibility.h 437 | 438 | 439 | 440 | NSObject 441 | 442 | IBFrameworkSource 443 | UIKit.framework/Headers/UINibLoading.h 444 | 445 | 446 | 447 | NSObject 448 | 449 | IBFrameworkSource 450 | UIKit.framework/Headers/UIResponder.h 451 | 452 | 453 | 454 | UIActivityIndicatorView 455 | UIView 456 | 457 | IBFrameworkSource 458 | UIKit.framework/Headers/UIActivityIndicatorView.h 459 | 460 | 461 | 462 | UIButton 463 | UIControl 464 | 465 | IBFrameworkSource 466 | UIKit.framework/Headers/UIButton.h 467 | 468 | 469 | 470 | UIControl 471 | UIView 472 | 473 | IBFrameworkSource 474 | UIKit.framework/Headers/UIControl.h 475 | 476 | 477 | 478 | UIResponder 479 | NSObject 480 | 481 | 482 | 483 | UIScrollView 484 | UIView 485 | 486 | IBFrameworkSource 487 | UIKit.framework/Headers/UIScrollView.h 488 | 489 | 490 | 491 | UISearchBar 492 | UIView 493 | 494 | IBFrameworkSource 495 | UIKit.framework/Headers/UISearchBar.h 496 | 497 | 498 | 499 | UISearchDisplayController 500 | NSObject 501 | 502 | IBFrameworkSource 503 | UIKit.framework/Headers/UISearchDisplayController.h 504 | 505 | 506 | 507 | UITextField 508 | UIControl 509 | 510 | IBFrameworkSource 511 | UIKit.framework/Headers/UITextField.h 512 | 513 | 514 | 515 | UITextView 516 | UIScrollView 517 | 518 | IBFrameworkSource 519 | UIKit.framework/Headers/UITextView.h 520 | 521 | 522 | 523 | UIView 524 | 525 | 526 | 527 | UIView 528 | UIResponder 529 | 530 | IBFrameworkSource 531 | UIKit.framework/Headers/UIView.h 532 | 533 | 534 | 535 | UIViewController 536 | 537 | IBFrameworkSource 538 | UIKit.framework/Headers/UINavigationController.h 539 | 540 | 541 | 542 | UIViewController 543 | 544 | IBFrameworkSource 545 | UIKit.framework/Headers/UITabBarController.h 546 | 547 | 548 | 549 | UIViewController 550 | UIResponder 551 | 552 | IBFrameworkSource 553 | UIKit.framework/Headers/UIViewController.h 554 | 555 | 556 | 557 | 558 | 0 559 | IBCocoaTouchFramework 560 | 561 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 562 | 563 | 564 | 565 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 566 | 567 | 568 | YES 569 | Chat.xcodeproj 570 | 3 571 | 82 572 | 573 | 574 | -------------------------------------------------------------------------------- /samples/Chat/Chat_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Chat' target in the 'Chat' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /samples/Chat/Classes/ChatAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChatAppDelegate.h 3 | // Chat 4 | // 5 | // Created by Esad Hajdarevic on 2/16/10. 6 | // Copyright OpenResearch Software Development OG 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ChatViewController; 12 | 13 | @interface ChatAppDelegate : NSObject { 14 | UIWindow *window; 15 | ChatViewController *viewController; 16 | } 17 | 18 | @property (nonatomic, retain) IBOutlet UIWindow *window; 19 | @property (nonatomic, retain) IBOutlet ChatViewController *viewController; 20 | 21 | @end 22 | 23 | -------------------------------------------------------------------------------- /samples/Chat/Classes/ChatAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // ChatAppDelegate.m 3 | // Chat 4 | // 5 | // Created by Esad Hajdarevic on 2/16/10. 6 | // Copyright OpenResearch Software Development OG 2010. All rights reserved. 7 | // 8 | 9 | #import "ChatAppDelegate.h" 10 | #import "ChatViewController.h" 11 | 12 | @implementation ChatAppDelegate 13 | 14 | @synthesize window; 15 | @synthesize viewController; 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | 20 | // Override point for customization after app launch 21 | [window addSubview:viewController.view]; 22 | [window makeKeyAndVisible]; 23 | 24 | return YES; 25 | } 26 | 27 | 28 | - (void)dealloc { 29 | [viewController release]; 30 | [window release]; 31 | [super dealloc]; 32 | } 33 | 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /samples/Chat/Classes/ChatTextView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChatTextView.h 3 | // Chat 4 | // 5 | // Created by Esad Hajdarevic on 2/16/10. 6 | // Copyright 2010 OpenResearch Software Development OG. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface ChatTextView : UITextView { 13 | 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /samples/Chat/Classes/ChatTextView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ChatTextView.m 3 | // Chat 4 | // 5 | // Created by Esad Hajdarevic on 2/16/10. 6 | // Copyright 2010 OpenResearch Software Development OG. All rights reserved. 7 | // 8 | 9 | #import "ChatTextView.h" 10 | 11 | 12 | @implementation ChatTextView 13 | 14 | -(BOOL)canBecomeFirstResponder { 15 | return NO; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /samples/Chat/Classes/ChatViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChatViewController.h 3 | // Chat 4 | // 5 | // Created by Esad Hajdarevic on 2/16/10. 6 | // Copyright OpenResearch Software Development OG 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Zimt/Zimt.h" 11 | 12 | @interface ChatViewController : UIViewController { 13 | ZTWebSocket* webSocket; 14 | IBOutlet UITextField* textField; 15 | IBOutlet UITextView* textView; 16 | IBOutlet UIActivityIndicatorView* activityIndicator; 17 | int messages; 18 | 19 | IBOutlet UIButton* reconnectButton; 20 | } 21 | 22 | -(IBAction)reconnect:(id)sender; 23 | @end -------------------------------------------------------------------------------- /samples/Chat/Classes/ChatViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ChatViewController.m 3 | // Chat 4 | // 5 | // Created by Esad Hajdarevic on 2/16/10. 6 | // Copyright OpenResearch Software Development OG 2010. All rights reserved. 7 | // 8 | 9 | #import "ChatViewController.h" 10 | 11 | @implementation ChatViewController 12 | 13 | -(void)write:(NSString*)text { 14 | NSMutableString* newText = [NSMutableString stringWithString:textView.text]; 15 | [newText appendString:text]; 16 | [newText appendString:@"\n"]; 17 | textView.text = newText; 18 | [textView scrollRangeToVisible:NSMakeRange([textView.text length]-1, 1)]; 19 | } 20 | 21 | -(void)viewDidLoad { 22 | webSocket = [[ZTWebSocket alloc] initWithURLString:@"ws://localhost:10000/" delegate:self]; 23 | [webSocket open]; 24 | [textField becomeFirstResponder]; 25 | } 26 | 27 | -(void)webSocketDidClose:(ZTWebSocket *)webSocket { 28 | [self write:@"Connection closed"]; 29 | reconnectButton.hidden = NO; 30 | } 31 | 32 | -(void)webSocket:(ZTWebSocket *)webSocket didFailWithError:(NSError *)error { 33 | if (error.code == ZTWebSocketErrorConnectionFailed) { 34 | [self write:@"Connection failed"]; 35 | } else if (error.code == ZTWebSocketErrorHandshakeFailed) { 36 | [self write:@"Handshake failed"]; 37 | } else { 38 | [self write:@"Error"]; 39 | } 40 | reconnectButton.hidden = NO; 41 | } 42 | 43 | -(void)webSocket:(ZTWebSocket *)webSocket didReceiveMessage:(NSString*)message { 44 | [self write:message]; 45 | } 46 | 47 | -(void)webSocketDidOpen:(ZTWebSocket *)aWebSocket { 48 | [self write:@"Connected"]; 49 | reconnectButton.hidden = YES; 50 | } 51 | 52 | -(void)webSocketDidSendMessage:(ZTWebSocket *)webSocket { 53 | messages--; 54 | if (messages == 0) { 55 | [activityIndicator stopAnimating]; 56 | } 57 | } 58 | 59 | - (BOOL)textFieldShouldReturn:(UITextField *)aTextField { 60 | if (webSocket.connected) { 61 | messages++; 62 | [activityIndicator startAnimating]; 63 | [webSocket send:aTextField.text]; 64 | } else { 65 | [self write:@"Cannot send message, not connected"]; 66 | } 67 | [textField setText:@""]; 68 | return NO; 69 | } 70 | 71 | -(IBAction)reconnect:(id)sender { 72 | if (!webSocket.connected) { 73 | [webSocket open]; 74 | } 75 | } 76 | 77 | -(void)dealloc { 78 | [webSocket release]; 79 | [super dealloc]; 80 | } 81 | @end 82 | -------------------------------------------------------------------------------- /samples/Chat/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 800 5 | 10D540 6 | 760 7 | 1038.29 8 | 460.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 81 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | IBCocoaTouchFramework 42 | 43 | 44 | ChatViewController 45 | 46 | IBCocoaTouchFramework 47 | 48 | 49 | 50 | 292 51 | {320, 480} 52 | 53 | 1 54 | MSAxIDEAA 55 | 56 | NO 57 | NO 58 | 59 | IBCocoaTouchFramework 60 | YES 61 | 62 | 63 | 64 | 65 | YES 66 | 67 | 68 | delegate 69 | 70 | 71 | 72 | 4 73 | 74 | 75 | 76 | viewController 77 | 78 | 79 | 80 | 11 81 | 82 | 83 | 84 | window 85 | 86 | 87 | 88 | 14 89 | 90 | 91 | 92 | 93 | YES 94 | 95 | 0 96 | 97 | 98 | 99 | 100 | 101 | -1 102 | 103 | 104 | File's Owner 105 | 106 | 107 | 3 108 | 109 | 110 | Chat App Delegate 111 | 112 | 113 | -2 114 | 115 | 116 | 117 | 118 | 10 119 | 120 | 121 | 122 | 123 | 12 124 | 125 | 126 | 127 | 128 | 129 | 130 | YES 131 | 132 | YES 133 | -1.CustomClassName 134 | -2.CustomClassName 135 | 10.CustomClassName 136 | 10.IBEditorWindowLastContentRect 137 | 10.IBPluginDependency 138 | 12.IBEditorWindowLastContentRect 139 | 12.IBPluginDependency 140 | 3.CustomClassName 141 | 3.IBPluginDependency 142 | 143 | 144 | YES 145 | UIApplication 146 | UIResponder 147 | ChatViewController 148 | {{234, 376}, {320, 480}} 149 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 150 | {{525, 346}, {320, 480}} 151 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 152 | ChatAppDelegate 153 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 154 | 155 | 156 | 157 | YES 158 | 159 | 160 | YES 161 | 162 | 163 | 164 | 165 | YES 166 | 167 | 168 | YES 169 | 170 | 171 | 172 | 14 173 | 174 | 175 | 176 | YES 177 | 178 | ChatAppDelegate 179 | NSObject 180 | 181 | YES 182 | 183 | YES 184 | viewController 185 | window 186 | 187 | 188 | YES 189 | ChatViewController 190 | UIWindow 191 | 192 | 193 | 194 | IBProjectSource 195 | Classes/ChatAppDelegate.h 196 | 197 | 198 | 199 | ChatAppDelegate 200 | NSObject 201 | 202 | IBUserSource 203 | 204 | 205 | 206 | 207 | ChatViewController 208 | UIViewController 209 | 210 | IBProjectSource 211 | Classes/ChatViewController.h 212 | 213 | 214 | 215 | 216 | 0 217 | IBCocoaTouchFramework 218 | 219 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 220 | 221 | 222 | YES 223 | Chat.xcodeproj 224 | 3 225 | 81 226 | 227 | 228 | -------------------------------------------------------------------------------- /samples/Chat/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Chat 4 | // 5 | // Created by Esad Hajdarevic on 2/16/10. 6 | // Copyright OpenResearch Software Development OG 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | [pool release]; 16 | return retVal; 17 | } 18 | -------------------------------------------------------------------------------- /samples/Chat/server.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'em-websocket' 3 | 4 | 5 | EventMachine.run { 6 | @channel = EM::Channel.new 7 | 8 | EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 10_000, :debug => true) do |ws| 9 | ws.onopen { 10 | @sid = @channel.subscribe { |msg| ws.send msg } 11 | @channel.push "#{@sid} connected!" 12 | } 13 | 14 | ws.onmessage { |msg| 15 | @channel.push "#{@sid}: #{msg}" 16 | } 17 | 18 | ws.onclose { 19 | puts "#{@sid} gone" 20 | @channel.unsubscribe(@sid) 21 | } 22 | end 23 | 24 | puts "Server started" 25 | 26 | Thread.new do 27 | while(true) do 28 | @channel.push "Server: ping" 29 | sleep 1 30 | end 31 | end 32 | } 33 | -------------------------------------------------------------------------------- /samples/FakeLocation/Classes/FakeLocationAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // FakeLocationAppDelegate.h 3 | // FakeLocation 4 | // 5 | // Created by Esad Hajdarevic on 2/13/10. 6 | // Copyright OpenResearch Software Development OG 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class FakeLocationViewController; 12 | 13 | @interface FakeLocationAppDelegate : NSObject { 14 | UIWindow *window; 15 | FakeLocationViewController *viewController; 16 | } 17 | 18 | @property (nonatomic, retain) IBOutlet UIWindow *window; 19 | @property (nonatomic, retain) IBOutlet FakeLocationViewController *viewController; 20 | 21 | @end 22 | 23 | -------------------------------------------------------------------------------- /samples/FakeLocation/Classes/FakeLocationAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // FakeLocationAppDelegate.m 3 | // FakeLocation 4 | // 5 | // Created by Esad Hajdarevic on 2/13/10. 6 | // Copyright OpenResearch Software Development OG 2010. All rights reserved. 7 | // 8 | 9 | #import "FakeLocationAppDelegate.h" 10 | #import "FakeLocationViewController.h" 11 | 12 | @implementation FakeLocationAppDelegate 13 | 14 | @synthesize window; 15 | @synthesize viewController; 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | 20 | // Override point for customization after app launch 21 | [window addSubview:viewController.view]; 22 | [window makeKeyAndVisible]; 23 | 24 | return YES; 25 | } 26 | 27 | 28 | - (void)dealloc { 29 | [viewController release]; 30 | [window release]; 31 | [super dealloc]; 32 | } 33 | 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /samples/FakeLocation/Classes/FakeLocationViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FakeLocationViewController.h 3 | // FakeLocation 4 | // 5 | // Created by Esad Hajdarevic on 2/13/10. 6 | // Copyright OpenResearch Software Development OG 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | @interface FakeLocationViewController : UIViewController { 14 | IBOutlet MKMapView* mapView; 15 | CLLocationManager* locationManager; 16 | CLLocation* location; 17 | } 18 | 19 | @property(readwrite,retain) CLLocation* location; 20 | 21 | @end 22 | 23 | -------------------------------------------------------------------------------- /samples/FakeLocation/Classes/FakeLocationViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FakeLocationViewController.m 3 | // FakeLocation 4 | // 5 | // Created by Esad Hajdarevic on 2/13/10. 6 | // Copyright OpenResearch Software Development OG 2010. All rights reserved. 7 | // 8 | 9 | #import "FakeLocationViewController.h" 10 | #import "Zimt/Zimt.h" 11 | 12 | @implementation FakeLocationViewController 13 | 14 | @synthesize location; 15 | 16 | - (void)viewDidLoad { 17 | [super viewDidLoad]; 18 | 19 | #if TARGET_IPHONE_SIMULATOR 20 | locationManager = [[ZTFakeLocationManager fakeLocationManagerWithContentsOfFile:@"vienna_ring.waypoints"] retain]; 21 | #else 22 | locationManager = [[CLLocationManager alloc] init]; 23 | #endif 24 | 25 | locationManager.delegate = self; 26 | [locationManager startUpdatingLocation]; 27 | 28 | 29 | mapView.delegate = self; 30 | } 31 | 32 | - (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id )annotation { 33 | MKAnnotationView* marker = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"userLocation"]; 34 | if (!marker) { 35 | marker = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"userLocation"] autorelease]; 36 | marker.image = [UIImage imageNamed:@"blue_dot.png"]; 37 | marker.annotation = annotation; 38 | marker.canShowCallout = NO; 39 | } 40 | return marker; 41 | } 42 | 43 | - (CLLocationCoordinate2D)coordinate { 44 | return self.location.coordinate; 45 | } 46 | 47 | - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 48 | self.location = newLocation; 49 | [mapView removeAnnotation:self]; 50 | [mapView addAnnotation:self]; 51 | 52 | 53 | [mapView setRegion:MKCoordinateRegionMakeWithDistance(newLocation.coordinate, 1000, 1000) animated:YES]; 54 | } 55 | 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /samples/FakeLocation/FakeLocation-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /samples/FakeLocation/FakeLocation.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 45; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1D3623260D0F684500981E51 /* FakeLocationAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* FakeLocationAppDelegate.m */; }; 11 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 12 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 13 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 14 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; 15 | 2899E5220DE3E06400AC0155 /* FakeLocationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E5210DE3E06400AC0155 /* FakeLocationViewController.xib */; }; 16 | 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; }; 17 | 28D7ACF80DDB3853001CB0EB /* FakeLocationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* FakeLocationViewController.m */; }; 18 | C77996A1112756FC00B197AE /* blue_dot.png in Resources */ = {isa = PBXBuildFile; fileRef = C77996A0112756FC00B197AE /* blue_dot.png */; }; 19 | C77996B61127577F00B197AE /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C77996B51127577F00B197AE /* MapKit.framework */; }; 20 | C7799721112758B500B197AE /* libZimt.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C77996E31127583900B197AE /* libZimt.a */; }; 21 | C779973C112758D300B197AE /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C779973B112758D300B197AE /* CoreLocation.framework */; }; 22 | C779975F1127595F00B197AE /* vienna_ring.waypoints in Resources */ = {isa = PBXBuildFile; fileRef = C779975E1127595F00B197AE /* vienna_ring.waypoints */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | C77996E21127583900B197AE /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = C77996DE1127583900B197AE /* Zimt.xcodeproj */; 29 | proxyType = 2; 30 | remoteGlobalIDString = D2AAC07E0554694100DB518D; 31 | remoteInfo = Zimt; 32 | }; 33 | C779971D112758AD00B197AE /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = C77996DE1127583900B197AE /* Zimt.xcodeproj */; 36 | proxyType = 1; 37 | remoteGlobalIDString = D2AAC07D0554694100DB518D; 38 | remoteInfo = Zimt; 39 | }; 40 | /* End PBXContainerItemProxy section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 44 | 1D3623240D0F684500981E51 /* FakeLocationAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeLocationAppDelegate.h; sourceTree = ""; }; 45 | 1D3623250D0F684500981E51 /* FakeLocationAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FakeLocationAppDelegate.m; sourceTree = ""; }; 46 | 1D6058910D05DD3D006BFB54 /* FakeLocation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FakeLocation.app; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 48 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 49 | 2899E5210DE3E06400AC0155 /* FakeLocationViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FakeLocationViewController.xib; sourceTree = ""; }; 50 | 28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; 51 | 28D7ACF60DDB3853001CB0EB /* FakeLocationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeLocationViewController.h; sourceTree = ""; }; 52 | 28D7ACF70DDB3853001CB0EB /* FakeLocationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FakeLocationViewController.m; sourceTree = ""; }; 53 | 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 54 | 32CA4F630368D1EE00C91783 /* FakeLocation_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeLocation_Prefix.pch; sourceTree = ""; }; 55 | 8D1107310486CEB800E47090 /* FakeLocation-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "FakeLocation-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; 56 | C77996A0112756FC00B197AE /* blue_dot.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = blue_dot.png; sourceTree = ""; }; 57 | C77996B51127577F00B197AE /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; 58 | C77996DE1127583900B197AE /* Zimt.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Zimt.xcodeproj; path = ../../src/Zimt.xcodeproj; sourceTree = SOURCE_ROOT; }; 59 | C779973B112758D300B197AE /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; 60 | C779975E1127595F00B197AE /* vienna_ring.waypoints */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = vienna_ring.waypoints; sourceTree = ""; }; 61 | /* End PBXFileReference section */ 62 | 63 | /* Begin PBXFrameworksBuildPhase section */ 64 | 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { 65 | isa = PBXFrameworksBuildPhase; 66 | buildActionMask = 2147483647; 67 | files = ( 68 | C7799721112758B500B197AE /* libZimt.a in Frameworks */, 69 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 70 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 71 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, 72 | C77996B61127577F00B197AE /* MapKit.framework in Frameworks */, 73 | C779973C112758D300B197AE /* CoreLocation.framework in Frameworks */, 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | /* End PBXFrameworksBuildPhase section */ 78 | 79 | /* Begin PBXGroup section */ 80 | 080E96DDFE201D6D7F000001 /* Classes */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 1D3623240D0F684500981E51 /* FakeLocationAppDelegate.h */, 84 | 1D3623250D0F684500981E51 /* FakeLocationAppDelegate.m */, 85 | 28D7ACF60DDB3853001CB0EB /* FakeLocationViewController.h */, 86 | 28D7ACF70DDB3853001CB0EB /* FakeLocationViewController.m */, 87 | ); 88 | path = Classes; 89 | sourceTree = ""; 90 | }; 91 | 19C28FACFE9D520D11CA2CBB /* Products */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 1D6058910D05DD3D006BFB54 /* FakeLocation.app */, 95 | ); 96 | name = Products; 97 | sourceTree = ""; 98 | }; 99 | 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | C77996DE1127583900B197AE /* Zimt.xcodeproj */, 103 | 080E96DDFE201D6D7F000001 /* Classes */, 104 | 29B97315FDCFA39411CA2CEA /* Other Sources */, 105 | 29B97317FDCFA39411CA2CEA /* Resources-iPhone */, 106 | 29B97323FDCFA39411CA2CEA /* Frameworks */, 107 | 19C28FACFE9D520D11CA2CBB /* Products */, 108 | ); 109 | name = CustomTemplate; 110 | sourceTree = ""; 111 | }; 112 | 29B97315FDCFA39411CA2CEA /* Other Sources */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 32CA4F630368D1EE00C91783 /* FakeLocation_Prefix.pch */, 116 | 29B97316FDCFA39411CA2CEA /* main.m */, 117 | ); 118 | name = "Other Sources"; 119 | sourceTree = ""; 120 | }; 121 | 29B97317FDCFA39411CA2CEA /* Resources-iPhone */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | C779975E1127595F00B197AE /* vienna_ring.waypoints */, 125 | C77996A0112756FC00B197AE /* blue_dot.png */, 126 | 2899E5210DE3E06400AC0155 /* FakeLocationViewController.xib */, 127 | 28AD733E0D9D9553002E5188 /* MainWindow.xib */, 128 | 8D1107310486CEB800E47090 /* FakeLocation-Info.plist */, 129 | ); 130 | name = "Resources-iPhone"; 131 | sourceTree = ""; 132 | }; 133 | 29B97323FDCFA39411CA2CEA /* Frameworks */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 137 | 1D30AB110D05D00D00671497 /* Foundation.framework */, 138 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */, 139 | C77996B51127577F00B197AE /* MapKit.framework */, 140 | C779973B112758D300B197AE /* CoreLocation.framework */, 141 | ); 142 | name = Frameworks; 143 | sourceTree = ""; 144 | }; 145 | C77996DF1127583900B197AE /* Products */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | C77996E31127583900B197AE /* libZimt.a */, 149 | ); 150 | name = Products; 151 | sourceTree = ""; 152 | }; 153 | /* End PBXGroup section */ 154 | 155 | /* Begin PBXNativeTarget section */ 156 | 1D6058900D05DD3D006BFB54 /* FakeLocation */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "FakeLocation" */; 159 | buildPhases = ( 160 | 1D60588D0D05DD3D006BFB54 /* Resources */, 161 | 1D60588E0D05DD3D006BFB54 /* Sources */, 162 | 1D60588F0D05DD3D006BFB54 /* Frameworks */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | C779971E112758AD00B197AE /* PBXTargetDependency */, 168 | ); 169 | name = FakeLocation; 170 | productName = FakeLocation; 171 | productReference = 1D6058910D05DD3D006BFB54 /* FakeLocation.app */; 172 | productType = "com.apple.product-type.application"; 173 | }; 174 | /* End PBXNativeTarget section */ 175 | 176 | /* Begin PBXProject section */ 177 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 178 | isa = PBXProject; 179 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "FakeLocation" */; 180 | compatibilityVersion = "Xcode 3.1"; 181 | hasScannedForEncodings = 1; 182 | mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; 183 | projectDirPath = ""; 184 | projectReferences = ( 185 | { 186 | ProductGroup = C77996DF1127583900B197AE /* Products */; 187 | ProjectRef = C77996DE1127583900B197AE /* Zimt.xcodeproj */; 188 | }, 189 | ); 190 | projectRoot = ""; 191 | targets = ( 192 | 1D6058900D05DD3D006BFB54 /* FakeLocation */, 193 | ); 194 | }; 195 | /* End PBXProject section */ 196 | 197 | /* Begin PBXReferenceProxy section */ 198 | C77996E31127583900B197AE /* libZimt.a */ = { 199 | isa = PBXReferenceProxy; 200 | fileType = archive.ar; 201 | path = libZimt.a; 202 | remoteRef = C77996E21127583900B197AE /* PBXContainerItemProxy */; 203 | sourceTree = BUILT_PRODUCTS_DIR; 204 | }; 205 | /* End PBXReferenceProxy section */ 206 | 207 | /* Begin PBXResourcesBuildPhase section */ 208 | 1D60588D0D05DD3D006BFB54 /* Resources */ = { 209 | isa = PBXResourcesBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */, 213 | 2899E5220DE3E06400AC0155 /* FakeLocationViewController.xib in Resources */, 214 | C77996A1112756FC00B197AE /* blue_dot.png in Resources */, 215 | C779975F1127595F00B197AE /* vienna_ring.waypoints in Resources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXResourcesBuildPhase section */ 220 | 221 | /* Begin PBXSourcesBuildPhase section */ 222 | 1D60588E0D05DD3D006BFB54 /* Sources */ = { 223 | isa = PBXSourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */, 227 | 1D3623260D0F684500981E51 /* FakeLocationAppDelegate.m in Sources */, 228 | 28D7ACF80DDB3853001CB0EB /* FakeLocationViewController.m in Sources */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXSourcesBuildPhase section */ 233 | 234 | /* Begin PBXTargetDependency section */ 235 | C779971E112758AD00B197AE /* PBXTargetDependency */ = { 236 | isa = PBXTargetDependency; 237 | name = Zimt; 238 | targetProxy = C779971D112758AD00B197AE /* PBXContainerItemProxy */; 239 | }; 240 | /* End PBXTargetDependency section */ 241 | 242 | /* Begin XCBuildConfiguration section */ 243 | 1D6058940D05DD3E006BFB54 /* Debug */ = { 244 | isa = XCBuildConfiguration; 245 | buildSettings = { 246 | ALWAYS_SEARCH_USER_PATHS = NO; 247 | COPY_PHASE_STRIP = NO; 248 | GCC_DYNAMIC_NO_PIC = NO; 249 | GCC_OPTIMIZATION_LEVEL = 0; 250 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 251 | GCC_PREFIX_HEADER = FakeLocation_Prefix.pch; 252 | INFOPLIST_FILE = "FakeLocation-Info.plist"; 253 | PRODUCT_NAME = FakeLocation; 254 | }; 255 | name = Debug; 256 | }; 257 | 1D6058950D05DD3E006BFB54 /* Release */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ALWAYS_SEARCH_USER_PATHS = NO; 261 | COPY_PHASE_STRIP = YES; 262 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 263 | GCC_PREFIX_HEADER = FakeLocation_Prefix.pch; 264 | INFOPLIST_FILE = "FakeLocation-Info.plist"; 265 | PRODUCT_NAME = FakeLocation; 266 | VALIDATE_PRODUCT = YES; 267 | }; 268 | name = Release; 269 | }; 270 | C01FCF4F08A954540054247B /* Debug */ = { 271 | isa = XCBuildConfiguration; 272 | buildSettings = { 273 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 274 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 275 | GCC_C_LANGUAGE_STANDARD = c99; 276 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 277 | GCC_WARN_UNUSED_VARIABLE = YES; 278 | PREBINDING = NO; 279 | SDKROOT = iphoneos3.2; 280 | USER_HEADER_SEARCH_PATHS = "../../src/**"; 281 | }; 282 | name = Debug; 283 | }; 284 | C01FCF5008A954540054247B /* Release */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 288 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 289 | GCC_C_LANGUAGE_STANDARD = c99; 290 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 291 | GCC_WARN_UNUSED_VARIABLE = YES; 292 | PREBINDING = NO; 293 | SDKROOT = iphoneos3.2; 294 | }; 295 | name = Release; 296 | }; 297 | /* End XCBuildConfiguration section */ 298 | 299 | /* Begin XCConfigurationList section */ 300 | 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "FakeLocation" */ = { 301 | isa = XCConfigurationList; 302 | buildConfigurations = ( 303 | 1D6058940D05DD3E006BFB54 /* Debug */, 304 | 1D6058950D05DD3E006BFB54 /* Release */, 305 | ); 306 | defaultConfigurationIsVisible = 0; 307 | defaultConfigurationName = Release; 308 | }; 309 | C01FCF4E08A954540054247B /* Build configuration list for PBXProject "FakeLocation" */ = { 310 | isa = XCConfigurationList; 311 | buildConfigurations = ( 312 | C01FCF4F08A954540054247B /* Debug */, 313 | C01FCF5008A954540054247B /* Release */, 314 | ); 315 | defaultConfigurationIsVisible = 0; 316 | defaultConfigurationName = Release; 317 | }; 318 | /* End XCConfigurationList section */ 319 | }; 320 | rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; 321 | } 322 | -------------------------------------------------------------------------------- /samples/FakeLocation/FakeLocationViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 800 5 | 10C540 6 | 759 7 | 1038.25 8 | 458.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 79 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | 42 | 274 43 | 44 | YES 45 | 46 | 47 | 274 48 | {320, 460} 49 | 50 | YES 51 | YES 52 | IBCocoaTouchFramework 53 | 54 | 55 | {320, 460} 56 | 57 | 58 | 3 59 | MC43NQA 60 | 61 | 2 62 | 63 | 64 | NO 65 | 66 | IBCocoaTouchFramework 67 | 68 | 69 | 70 | 71 | YES 72 | 73 | 74 | view 75 | 76 | 77 | 78 | 7 79 | 80 | 81 | 82 | mapView 83 | 84 | 85 | 86 | 9 87 | 88 | 89 | 90 | 91 | YES 92 | 93 | 0 94 | 95 | 96 | 97 | 98 | 99 | -1 100 | 101 | 102 | File's Owner 103 | 104 | 105 | -2 106 | 107 | 108 | 109 | 110 | 6 111 | 112 | 113 | YES 114 | 115 | 116 | 117 | 118 | 119 | 8 120 | 121 | 122 | 123 | 124 | 125 | 126 | YES 127 | 128 | YES 129 | -1.CustomClassName 130 | -2.CustomClassName 131 | 6.IBEditorWindowLastContentRect 132 | 6.IBPluginDependency 133 | 8.IBPluginDependency 134 | 135 | 136 | YES 137 | FakeLocationViewController 138 | UIResponder 139 | {{239, 276}, {320, 480}} 140 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 141 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 142 | 143 | 144 | 145 | YES 146 | 147 | 148 | YES 149 | 150 | 151 | 152 | 153 | YES 154 | 155 | 156 | YES 157 | 158 | 159 | 160 | 9 161 | 162 | 163 | 164 | YES 165 | 166 | FakeLocationViewController 167 | UIViewController 168 | 169 | mapView 170 | MKMapView 171 | 172 | 173 | IBProjectSource 174 | Classes/FakeLocationViewController.h 175 | 176 | 177 | 178 | 179 | YES 180 | 181 | NSObject 182 | 183 | IBFrameworkSource 184 | Foundation.framework/Headers/NSError.h 185 | 186 | 187 | 188 | NSObject 189 | 190 | IBFrameworkSource 191 | Foundation.framework/Headers/NSFileManager.h 192 | 193 | 194 | 195 | NSObject 196 | 197 | IBFrameworkSource 198 | Foundation.framework/Headers/NSKeyValueCoding.h 199 | 200 | 201 | 202 | NSObject 203 | 204 | IBFrameworkSource 205 | Foundation.framework/Headers/NSKeyValueObserving.h 206 | 207 | 208 | 209 | NSObject 210 | 211 | IBFrameworkSource 212 | Foundation.framework/Headers/NSKeyedArchiver.h 213 | 214 | 215 | 216 | NSObject 217 | 218 | IBFrameworkSource 219 | Foundation.framework/Headers/NSNetServices.h 220 | 221 | 222 | 223 | NSObject 224 | 225 | IBFrameworkSource 226 | Foundation.framework/Headers/NSObject.h 227 | 228 | 229 | 230 | NSObject 231 | 232 | IBFrameworkSource 233 | Foundation.framework/Headers/NSPort.h 234 | 235 | 236 | 237 | NSObject 238 | 239 | IBFrameworkSource 240 | Foundation.framework/Headers/NSRunLoop.h 241 | 242 | 243 | 244 | NSObject 245 | 246 | IBFrameworkSource 247 | Foundation.framework/Headers/NSStream.h 248 | 249 | 250 | 251 | NSObject 252 | 253 | IBFrameworkSource 254 | Foundation.framework/Headers/NSThread.h 255 | 256 | 257 | 258 | NSObject 259 | 260 | IBFrameworkSource 261 | Foundation.framework/Headers/NSURL.h 262 | 263 | 264 | 265 | NSObject 266 | 267 | IBFrameworkSource 268 | Foundation.framework/Headers/NSURLConnection.h 269 | 270 | 271 | 272 | NSObject 273 | 274 | IBFrameworkSource 275 | Foundation.framework/Headers/NSXMLParser.h 276 | 277 | 278 | 279 | NSObject 280 | 281 | IBFrameworkSource 282 | UIKit.framework/Headers/UIAccessibility.h 283 | 284 | 285 | 286 | NSObject 287 | 288 | IBFrameworkSource 289 | UIKit.framework/Headers/UINibLoading.h 290 | 291 | 292 | 293 | NSObject 294 | 295 | IBFrameworkSource 296 | UIKit.framework/Headers/UIResponder.h 297 | 298 | 299 | 300 | UIResponder 301 | NSObject 302 | 303 | 304 | 305 | UISearchBar 306 | UIView 307 | 308 | IBFrameworkSource 309 | UIKit.framework/Headers/UISearchBar.h 310 | 311 | 312 | 313 | UISearchDisplayController 314 | NSObject 315 | 316 | IBFrameworkSource 317 | UIKit.framework/Headers/UISearchDisplayController.h 318 | 319 | 320 | 321 | UIView 322 | 323 | IBFrameworkSource 324 | UIKit.framework/Headers/UITextField.h 325 | 326 | 327 | 328 | UIView 329 | UIResponder 330 | 331 | IBFrameworkSource 332 | UIKit.framework/Headers/UIView.h 333 | 334 | 335 | 336 | UIViewController 337 | 338 | IBFrameworkSource 339 | UIKit.framework/Headers/UINavigationController.h 340 | 341 | 342 | 343 | UIViewController 344 | 345 | IBFrameworkSource 346 | UIKit.framework/Headers/UIPopoverController.h 347 | 348 | 349 | 350 | UIViewController 351 | 352 | IBFrameworkSource 353 | UIKit.framework/Headers/UISplitViewController.h 354 | 355 | 356 | 357 | UIViewController 358 | 359 | IBFrameworkSource 360 | UIKit.framework/Headers/UITabBarController.h 361 | 362 | 363 | 364 | UIViewController 365 | UIResponder 366 | 367 | IBFrameworkSource 368 | UIKit.framework/Headers/UIViewController.h 369 | 370 | 371 | 372 | 373 | 0 374 | IBCocoaTouchFramework 375 | 376 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 377 | 378 | 379 | 380 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 381 | 382 | 383 | YES 384 | FakeLocation.xcodeproj 385 | 3 386 | 79 387 | 388 | 389 | 390 | -------------------------------------------------------------------------------- /samples/FakeLocation/FakeLocation_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'FakeLocation' target in the 'FakeLocation' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /samples/FakeLocation/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 800 5 | 10C540 6 | 759 7 | 1038.25 8 | 458.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 77 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | IBCocoaTouchFramework 42 | 43 | 44 | FakeLocationViewController 45 | 46 | IBCocoaTouchFramework 47 | 48 | 49 | 50 | 292 51 | {320, 480} 52 | 53 | 1 54 | MSAxIDEAA 55 | 56 | NO 57 | NO 58 | 59 | IBCocoaTouchFramework 60 | 61 | 62 | 63 | 64 | YES 65 | 66 | 67 | delegate 68 | 69 | 70 | 71 | 4 72 | 73 | 74 | 75 | viewController 76 | 77 | 78 | 79 | 11 80 | 81 | 82 | 83 | window 84 | 85 | 86 | 87 | 14 88 | 89 | 90 | 91 | 92 | YES 93 | 94 | 0 95 | 96 | 97 | 98 | 99 | 100 | -1 101 | 102 | 103 | File's Owner 104 | 105 | 106 | 3 107 | 108 | 109 | FakeLocation App Delegate 110 | 111 | 112 | -2 113 | 114 | 115 | 116 | 117 | 10 118 | 119 | 120 | 121 | 122 | 12 123 | 124 | 125 | 126 | 127 | 128 | 129 | YES 130 | 131 | YES 132 | -1.CustomClassName 133 | -2.CustomClassName 134 | 10.CustomClassName 135 | 10.IBEditorWindowLastContentRect 136 | 10.IBPluginDependency 137 | 12.IBEditorWindowLastContentRect 138 | 12.IBPluginDependency 139 | 3.CustomClassName 140 | 3.IBPluginDependency 141 | 142 | 143 | YES 144 | UIApplication 145 | UIResponder 146 | FakeLocationViewController 147 | {{234, 654}, {320, 480}} 148 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 149 | {{525, 346}, {320, 480}} 150 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 151 | FakeLocationAppDelegate 152 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 153 | 154 | 155 | 156 | YES 157 | 158 | 159 | YES 160 | 161 | 162 | 163 | 164 | YES 165 | 166 | 167 | YES 168 | 169 | 170 | 171 | 14 172 | 173 | 174 | 175 | YES 176 | 177 | FakeLocationAppDelegate 178 | NSObject 179 | 180 | YES 181 | 182 | YES 183 | viewController 184 | window 185 | 186 | 187 | YES 188 | FakeLocationViewController 189 | UIWindow 190 | 191 | 192 | 193 | IBProjectSource 194 | Classes/FakeLocationAppDelegate.h 195 | 196 | 197 | 198 | FakeLocationAppDelegate 199 | NSObject 200 | 201 | IBUserSource 202 | 203 | 204 | 205 | 206 | FakeLocationViewController 207 | UIViewController 208 | 209 | IBProjectSource 210 | Classes/FakeLocationViewController.h 211 | 212 | 213 | 214 | 215 | 0 216 | IBCocoaTouchFramework 217 | 218 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 219 | 220 | 221 | YES 222 | FakeLocation.xcodeproj 223 | 3 224 | 77 225 | 226 | 227 | 228 | -------------------------------------------------------------------------------- /samples/FakeLocation/blue_dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esad/zimt/39665286bf80dfcc38839870430b2a4350a8f39a/samples/FakeLocation/blue_dot.png -------------------------------------------------------------------------------- /samples/FakeLocation/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // FakeLocation 4 | // 5 | // Created by Esad Hajdarevic on 2/13/10. 6 | // Copyright OpenResearch Software Development OG 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | [pool release]; 16 | return retVal; 17 | } 18 | -------------------------------------------------------------------------------- /samples/FakeLocation/vienna_ring.waypoints: -------------------------------------------------------------------------------- 1 | 48.205229,16.362025 2 | 48.205699,16.361396 3 | 48.206058,16.360935 4 | 48.206572,16.360249 5 | 48.206976,16.359732 6 | 48.207718,16.359913 7 | 48.208502,16.360145 8 | 48.209297,16.360381 9 | 48.210666,16.360781 10 | 48.212548,16.361307 11 | 48.213478,16.361642 12 | 48.214479,16.363777 13 | 48.215371,16.365715 14 | 48.216217,16.367574 15 | -------------------------------------------------------------------------------- /src/Vendor/AsyncSocket/AsyncSocket.h: -------------------------------------------------------------------------------- 1 | // 2 | // AsyncSocket.h 3 | // 4 | // This class is in the public domain. 5 | // Originally created by Dustin Voss on Wed Jan 29 2003. 6 | // Updated and maintained by Deusty Designs and the Mac development community. 7 | // 8 | // http://code.google.com/p/cocoaasyncsocket/ 9 | // 10 | 11 | #import 12 | 13 | @class AsyncSocket; 14 | @class AsyncReadPacket; 15 | @class AsyncWritePacket; 16 | 17 | extern NSString *const AsyncSocketException; 18 | extern NSString *const AsyncSocketErrorDomain; 19 | 20 | enum AsyncSocketError 21 | { 22 | AsyncSocketCFSocketError = kCFSocketError, // From CFSocketError enum. 23 | AsyncSocketNoError = 0, // Never used. 24 | AsyncSocketCanceledError, // onSocketWillConnect: returned NO. 25 | AsyncSocketConnectTimeoutError, 26 | AsyncSocketReadMaxedOutError, // Reached set maxLength without completing 27 | AsyncSocketReadTimeoutError, 28 | AsyncSocketWriteTimeoutError 29 | }; 30 | typedef enum AsyncSocketError AsyncSocketError; 31 | 32 | @interface NSObject (AsyncSocketDelegate) 33 | 34 | /** 35 | * In the event of an error, the socket is closed. 36 | * You may call "unreadData" during this call-back to get the last bit of data off the socket. 37 | * When connecting, this delegate method may be called 38 | * before"onSocket:didAcceptNewSocket:" or "onSocket:didConnectToHost:". 39 | **/ 40 | - (void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err; 41 | 42 | /** 43 | * Called when a socket disconnects with or without error. If you want to release a socket after it disconnects, 44 | * do so here. It is not safe to do that during "onSocket:willDisconnectWithError:". 45 | * 46 | * If you call the disconnect method, and the socket wasn't already disconnected, 47 | * this delegate method will be called before the disconnect method returns. 48 | **/ 49 | - (void)onSocketDidDisconnect:(AsyncSocket *)sock; 50 | 51 | /** 52 | * Called when a socket accepts a connection. Another socket is spawned to handle it. The new socket will have 53 | * the same delegate and will call "onSocket:didConnectToHost:port:". 54 | **/ 55 | - (void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket; 56 | 57 | /** 58 | * Called when a new socket is spawned to handle a connection. This method should return the run-loop of the 59 | * thread on which the new socket and its delegate should operate. If omitted, [NSRunLoop currentRunLoop] is used. 60 | **/ 61 | - (NSRunLoop *)onSocket:(AsyncSocket *)sock wantsRunLoopForNewSocket:(AsyncSocket *)newSocket; 62 | 63 | /** 64 | * Called when a socket is about to connect. This method should return YES to continue, or NO to abort. 65 | * If aborted, will result in AsyncSocketCanceledError. 66 | * 67 | * If the connectToHost:onPort:error: method was called, the delegate will be able to access and configure the 68 | * CFReadStream and CFWriteStream as desired prior to connection. 69 | * 70 | * If the connectToAddress:error: method was called, the delegate will be able to access and configure the 71 | * CFSocket and CFSocketNativeHandle (BSD socket) as desired prior to connection. You will be able to access and 72 | * configure the CFReadStream and CFWriteStream in the onSocket:didConnectToHost:port: method. 73 | **/ 74 | - (BOOL)onSocketWillConnect:(AsyncSocket *)sock; 75 | 76 | /** 77 | * Called when a socket connects and is ready for reading and writing. 78 | * The host parameter will be an IP address, not a DNS name. 79 | **/ 80 | - (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port; 81 | 82 | /** 83 | * Called when a socket has completed reading the requested data into memory. 84 | * Not called if there is an error. 85 | **/ 86 | - (void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag; 87 | 88 | /** 89 | * Called when a socket has read in data, but has not yet completed the read. 90 | * This would occur if using readToData: or readToLength: methods. 91 | * It may be used to for things such as updating progress bars. 92 | **/ 93 | - (void)onSocket:(AsyncSocket *)sock didReadPartialDataOfLength:(CFIndex)partialLength tag:(long)tag; 94 | 95 | /** 96 | * Called when a socket has completed writing the requested data. Not called if there is an error. 97 | **/ 98 | - (void)onSocket:(AsyncSocket *)sock didWriteDataWithTag:(long)tag; 99 | 100 | /** 101 | * Called when a socket has written some data, but has not yet completed the entire write. 102 | * It may be used to for things such as updating progress bars. 103 | **/ 104 | - (void)onSocket:(AsyncSocket *)sock didWritePartialDataOfLength:(CFIndex)partialLength tag:(long)tag; 105 | 106 | /** 107 | * Called if a read operation has reached its timeout without completing. 108 | * This method allows you to optionally extend the timeout. 109 | * If you return a positive time interval (> 0) the read's timeout will be extended by the given amount. 110 | * If you don't implement this method, or return a non-positive time interval (<= 0) the read will timeout as usual. 111 | * 112 | * The elapsed parameter is the sum of the original timeout, plus any additions previously added via this method. 113 | * The length parameter is the number of bytes that have been read so far for the read operation. 114 | * 115 | * Note that this method may be called multiple times for a single read if you return positive numbers. 116 | **/ 117 | - (NSTimeInterval)onSocket:(AsyncSocket *)sock 118 | shouldTimeoutReadWithTag:(long)tag 119 | elapsed:(NSTimeInterval)elapsed 120 | bytesDone:(CFIndex)length; 121 | 122 | /** 123 | * Called if a write operation has reached its timeout without completing. 124 | * This method allows you to optionally extend the timeout. 125 | * If you return a positive time interval (> 0) the write's timeout will be extended by the given amount. 126 | * If you don't implement this method, or return a non-positive time interval (<= 0) the write will timeout as usual. 127 | * 128 | * The elapsed parameter is the sum of the original timeout, plus any additions previously added via this method. 129 | * The length parameter is the number of bytes that have been written so far for the write operation. 130 | * 131 | * Note that this method may be called multiple times for a single write if you return positive numbers. 132 | **/ 133 | - (NSTimeInterval)onSocket:(AsyncSocket *)sock 134 | shouldTimeoutWriteWithTag:(long)tag 135 | elapsed:(NSTimeInterval)elapsed 136 | bytesDone:(CFIndex)length; 137 | 138 | /** 139 | * Called after the socket has successfully completed SSL/TLS negotiation. 140 | * This method is not called unless you use the provided startTLS method. 141 | * 142 | * If a SSL/TLS negotiation fails (invalid certificate, etc) then the socket will immediately close, 143 | * and the onSocket:willDisconnectWithError: delegate method will be called with the specific SSL error code. 144 | **/ 145 | - (void)onSocketDidSecure:(AsyncSocket *)sock; 146 | 147 | @end 148 | 149 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 150 | #pragma mark - 151 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 152 | 153 | @interface AsyncSocket : NSObject 154 | { 155 | CFSocketRef theSocket4; // IPv4 accept or connect socket 156 | CFSocketRef theSocket6; // IPv6 accept or connect socket 157 | CFReadStreamRef theReadStream; 158 | CFWriteStreamRef theWriteStream; 159 | 160 | CFRunLoopSourceRef theSource4; // For theSocket4 161 | CFRunLoopSourceRef theSource6; // For theSocket6 162 | CFRunLoopRef theRunLoop; 163 | CFSocketContext theContext; 164 | NSArray *theRunLoopModes; 165 | 166 | NSTimer *theConnectTimer; 167 | 168 | NSMutableArray *theReadQueue; 169 | AsyncReadPacket *theCurrentRead; 170 | NSTimer *theReadTimer; 171 | NSMutableData *partialReadBuffer; 172 | 173 | NSMutableArray *theWriteQueue; 174 | AsyncWritePacket *theCurrentWrite; 175 | NSTimer *theWriteTimer; 176 | 177 | id theDelegate; 178 | UInt16 theFlags; 179 | 180 | long theUserData; 181 | } 182 | 183 | - (id)init; 184 | - (id)initWithDelegate:(id)delegate; 185 | - (id)initWithDelegate:(id)delegate userData:(long)userData; 186 | 187 | /* String representation is long but has no "\n". */ 188 | - (NSString *)description; 189 | 190 | /** 191 | * Use "canSafelySetDelegate" to see if there is any pending business (reads and writes) with the current delegate 192 | * before changing it. It is, of course, safe to change the delegate before connecting or accepting connections. 193 | **/ 194 | - (id)delegate; 195 | - (BOOL)canSafelySetDelegate; 196 | - (void)setDelegate:(id)delegate; 197 | 198 | /* User data can be a long, or an id or void * cast to a long. */ 199 | - (long)userData; 200 | - (void)setUserData:(long)userData; 201 | 202 | /* Don't use these to read or write. And don't close them either! */ 203 | - (CFSocketRef)getCFSocket; 204 | - (CFReadStreamRef)getCFReadStream; 205 | - (CFWriteStreamRef)getCFWriteStream; 206 | 207 | // Once one of the accept or connect methods are called, the AsyncSocket instance is locked in 208 | // and the other accept/connect methods can't be called without disconnecting the socket first. 209 | // If the attempt fails or times out, these methods either return NO or 210 | // call "onSocket:willDisconnectWithError:" and "onSockedDidDisconnect:". 211 | 212 | // When an incoming connection is accepted, AsyncSocket invokes several delegate methods. 213 | // These methods are (in chronological order): 214 | // 1. onSocket:didAcceptNewSocket: 215 | // 2. onSocket:wantsRunLoopForNewSocket: 216 | // 3. onSocketWillConnect: 217 | // 218 | // Your server code will need to retain the accepted socket (if you want to accept it). 219 | // The best place to do this is probably in the onSocket:didAcceptNewSocket: method. 220 | // 221 | // After the read and write streams have been setup for the newly accepted socket, 222 | // the onSocket:didConnectToHost:port: method will be called on the proper run loop. 223 | // 224 | // Multithreading Note: If you're going to be moving the newly accepted socket to another run 225 | // loop by implementing onSocket:wantsRunLoopForNewSocket:, then you should wait until the 226 | // onSocket:didConnectToHost:port: method before calling read, write, or startTLS methods. 227 | // Otherwise read/write events are scheduled on the incorrect runloop, and chaos may ensue. 228 | 229 | /** 230 | * Tells the socket to begin listening and accepting connections on the given port. 231 | * When a connection comes in, the AsyncSocket instance will call the various delegate methods (see above). 232 | * The socket will listen on all available interfaces (e.g. wifi, ethernet, etc) 233 | **/ 234 | - (BOOL)acceptOnPort:(UInt16)port error:(NSError **)errPtr; 235 | 236 | /** 237 | * This method is the same as acceptOnPort:error: with the additional option 238 | * of specifying which interface to listen on. So, for example, if you were writing code for a server that 239 | * has multiple IP addresses, you could specify which address you wanted to listen on. Or you could use it 240 | * to specify that the socket should only accept connections over ethernet, and not other interfaces such as wifi. 241 | * You may also use the special strings "localhost" or "loopback" to specify that 242 | * the socket only accept connections from the local machine. 243 | * 244 | * To accept connections on any interface pass nil, or simply use the acceptOnPort:error: method. 245 | **/ 246 | - (BOOL)acceptOnInterface:(NSString *)interface port:(UInt16)port error:(NSError **)errPtr; 247 | 248 | /** 249 | * Connects to the given host and port. 250 | * The host may be a domain name (e.g. "deusty.com") or an IP address string (e.g. "192.168.0.2") 251 | **/ 252 | - (BOOL)connectToHost:(NSString *)hostname onPort:(UInt16)port error:(NSError **)errPtr; 253 | 254 | /** 255 | * This method is the same as connectToHost:onPort:error: with an additional timeout option. 256 | * To not time out use a negative time interval, or simply use the connectToHost:onPort:error: method. 257 | **/ 258 | - (BOOL)connectToHost:(NSString *)hostname 259 | onPort:(UInt16)port 260 | withTimeout:(NSTimeInterval)timeout 261 | error:(NSError **)errPtr; 262 | 263 | /** 264 | * Connects to the given address, specified as a sockaddr structure wrapped in a NSData object. 265 | * For example, a NSData object returned from NSNetservice's addresses method. 266 | * 267 | * If you have an existing struct sockaddr you can convert it to a NSData object like so: 268 | * struct sockaddr sa -> NSData *dsa = [NSData dataWithBytes:&remoteAddr length:remoteAddr.sa_len]; 269 | * struct sockaddr *sa -> NSData *dsa = [NSData dataWithBytes:remoteAddr length:remoteAddr->sa_len]; 270 | **/ 271 | - (BOOL)connectToAddress:(NSData *)remoteAddr error:(NSError **)errPtr; 272 | 273 | /** 274 | * This method is the same as connectToAddress:error: with an additional timeout option. 275 | * To not time out use a negative time interval, or simply use the connectToAddress:error: method. 276 | **/ 277 | - (BOOL)connectToAddress:(NSData *)remoteAddr withTimeout:(NSTimeInterval)timeout error:(NSError **)errPtr; 278 | 279 | /** 280 | * Disconnects immediately. Any pending reads or writes are dropped. 281 | * If the socket is not already disconnected, the onSocketDidDisconnect delegate method 282 | * will be called immediately, before this method returns. 283 | * 284 | * Please note the recommended way of releasing an AsyncSocket instance (e.g. in a dealloc method) 285 | * [asyncSocket setDelegate:nil]; 286 | * [asyncSocket disconnect]; 287 | * [asyncSocket release]; 288 | **/ 289 | - (void)disconnect; 290 | 291 | /** 292 | * Disconnects after all pending reads have completed. 293 | * After calling this, the read and write methods will do nothing. 294 | * The socket will disconnect even if there are still pending writes. 295 | **/ 296 | - (void)disconnectAfterReading; 297 | 298 | /** 299 | * Disconnects after all pending writes have completed. 300 | * After calling this, the read and write methods will do nothing. 301 | * The socket will disconnect even if there are still pending reads. 302 | **/ 303 | - (void)disconnectAfterWriting; 304 | 305 | /** 306 | * Disconnects after all pending reads and writes have completed. 307 | * After calling this, the read and write methods will do nothing. 308 | **/ 309 | - (void)disconnectAfterReadingAndWriting; 310 | 311 | /* Returns YES if the socket and streams are open, connected, and ready for reading and writing. */ 312 | - (BOOL)isConnected; 313 | 314 | /** 315 | * Returns the local or remote host and port to which this socket is connected, or nil and 0 if not connected. 316 | * The host will be an IP address. 317 | **/ 318 | - (NSString *)connectedHost; 319 | - (UInt16)connectedPort; 320 | 321 | - (NSString *)localHost; 322 | - (UInt16)localPort; 323 | 324 | /** 325 | * Returns the local or remote address to which this socket is connected, 326 | * specified as a sockaddr structure wrapped in a NSData object. 327 | * 328 | * See also the connectedHost, connectedPort, localHost and localPort methods. 329 | **/ 330 | - (NSData *)connectedAddress; 331 | - (NSData *)localAddress; 332 | 333 | /** 334 | * Returns whether the socket is IPv4 or IPv6. 335 | * An accepting socket may be both. 336 | **/ 337 | - (BOOL)isIPv4; 338 | - (BOOL)isIPv6; 339 | 340 | // The readData and writeData methods won't block. 341 | // 342 | // You may optionally set a timeout for any read/write operation. (To not timeout, use a negative time interval.) 343 | // If a read/write opertion times out, the corresponding "onSocket:shouldTimeout..." delegate method 344 | // is called to optionally allow you to extend the timeout. 345 | // Upon a timeout, the "onSocket:willDisconnectWithError:" method is called, followed by "onSocketDidDisconnect". 346 | // 347 | // The tag is for your convenience. 348 | // You can use it as an array index, step number, state id, pointer, etc., just like the socket's user data. 349 | 350 | /** 351 | * This will read a certain number of bytes into memory, and call the delegate method when those bytes have been read. 352 | * 353 | * If the length is 0, this method does nothing and the delegate is not called. 354 | * If the timeout value is negative, the read operation will not use a timeout. 355 | **/ 356 | - (void)readDataToLength:(CFIndex)length withTimeout:(NSTimeInterval)timeout tag:(long)tag; 357 | 358 | /** 359 | * This reads bytes until (and including) the passed "data" parameter, which acts as a separator. 360 | * The bytes and the separator are returned by the delegate method. 361 | * 362 | * If you pass nil or zero-length data as the "data" parameter, 363 | * the method will do nothing, and the delegate will not be called. 364 | * If the timeout value is negative, the read operation will not use a timeout. 365 | * 366 | * To read a line from the socket, use the line separator (e.g. CRLF for HTTP, see below) as the "data" parameter. 367 | * Note that this method is not character-set aware, so if a separator can occur naturally as part of the encoding for 368 | * a character, the read will prematurely end. 369 | **/ 370 | - (void)readDataToData:(NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag; 371 | 372 | /** 373 | * Same as readDataToData:withTimeout:tag, with the additional restriction that the amount of data read 374 | * may not surpass the given maxLength (specified in bytes). 375 | * 376 | * If you pass a maxLength parameter that is less than the length of the data parameter, 377 | * the method will do nothing, and the delegate will not be called. 378 | * 379 | * If the max length is surpassed, it is treated the same as a timeout - the socket is closed. 380 | * 381 | * Pass -1 as maxLength if no length restriction is desired, or simply use the readDataToData:withTimeout:tag method. 382 | **/ 383 | - (void)readDataToData:(NSData *)data withTimeout:(NSTimeInterval)timeout maxLength:(CFIndex)length tag:(long)tag; 384 | 385 | /** 386 | * Reads the first available bytes that become available on the socket. 387 | * 388 | * If the timeout value is negative, the read operation will not use a timeout. 389 | **/ 390 | - (void)readDataWithTimeout:(NSTimeInterval)timeout tag:(long)tag; 391 | 392 | /** 393 | * Writes data to the socket, and calls the delegate when finished. 394 | * 395 | * If you pass in nil or zero-length data, this method does nothing and the delegate will not be called. 396 | * If the timeout value is negative, the write operation will not use a timeout. 397 | **/ 398 | - (void)writeData:(NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag; 399 | 400 | /** 401 | * Returns progress of current read or write, from 0.0 to 1.0, or NaN if no read/write (use isnan() to check). 402 | * "tag", "done" and "total" will be filled in if they aren't NULL. 403 | **/ 404 | - (float)progressOfReadReturningTag:(long *)tag bytesDone:(CFIndex *)done total:(CFIndex *)total; 405 | - (float)progressOfWriteReturningTag:(long *)tag bytesDone:(CFIndex *)done total:(CFIndex *)total; 406 | 407 | /** 408 | * Secures the connection using SSL/TLS. 409 | * 410 | * This method may be called at any time, and the TLS handshake will occur after all pending reads and writes 411 | * are finished. This allows one the option of sending a protocol dependent StartTLS message, and queuing 412 | * the upgrade to TLS at the same time, without having to wait for the write to finish. 413 | * Any reads or writes scheduled after this method is called will occur over the secured connection. 414 | * 415 | * The possible keys and values for the TLS settings are well documented. 416 | * Some possible keys are: 417 | * - kCFStreamSSLLevel 418 | * - kCFStreamSSLAllowsExpiredCertificates 419 | * - kCFStreamSSLAllowsExpiredRoots 420 | * - kCFStreamSSLAllowsAnyRoot 421 | * - kCFStreamSSLValidatesCertificateChain 422 | * - kCFStreamSSLPeerName 423 | * - kCFStreamSSLCertificates 424 | * - kCFStreamSSLIsServer 425 | * 426 | * Please refer to Apple's documentation for associated values, as well as other possible keys. 427 | * 428 | * If you pass in nil or an empty dictionary, the default settings will be used. 429 | * 430 | * The default settings will check to make sure the remote party's certificate is signed by a 431 | * trusted 3rd party certificate agency (e.g. verisign) and that the certificate is not expired. 432 | * However it will not verify the name on the certificate unless you 433 | * give it a name to verify against via the kCFStreamSSLPeerName key. 434 | * The security implications of this are important to understand. 435 | * Imagine you are attempting to create a secure connection to MySecureServer.com, 436 | * but your socket gets directed to MaliciousServer.com because of a hacked DNS server. 437 | * If you simply use the default settings, and MaliciousServer.com has a valid certificate, 438 | * the default settings will not detect any problems since the certificate is valid. 439 | * To properly secure your connection in this particular scenario you 440 | * should set the kCFStreamSSLPeerName property to "MySecureServer.com". 441 | * If you do not know the peer name of the remote host in advance (for example, you're not sure 442 | * if it will be "domain.com" or "www.domain.com"), then you can use the default settings to validate the 443 | * certificate, and then use the X509Certificate class to verify the issuer after the socket has been secured. 444 | * The X509Certificate class is part of the CocoaAsyncSocket open source project. 445 | **/ 446 | - (void)startTLS:(NSDictionary *)tlsSettings; 447 | 448 | /** 449 | * For handling readDataToData requests, data is necessarily read from the socket in small increments. 450 | * The performance can be much improved by allowing AsyncSocket to read larger chunks at a time and 451 | * store any overflow in a small internal buffer. 452 | * This is termed pre-buffering, as some data may be read for you before you ask for it. 453 | * If you use readDataToData a lot, enabling pre-buffering will result in better performance, especially on the iPhone. 454 | * 455 | * The default pre-buffering state is controlled by the DEFAULT_PREBUFFERING definition. 456 | * It is highly recommended one leave this set to YES. 457 | * 458 | * This method exists in case pre-buffering needs to be disabled by default for some unforeseen reason. 459 | * In that case, this method exists to allow one to easily enable pre-buffering when ready. 460 | **/ 461 | - (void)enablePreBuffering; 462 | 463 | /** 464 | * When you create an AsyncSocket, it is added to the runloop of the current thread. 465 | * So for manually created sockets, it is easiest to simply create the socket on the thread you intend to use it. 466 | * 467 | * If a new socket is accepted, the delegate method onSocket:wantsRunLoopForNewSocket: is called to 468 | * allow you to place the socket on a separate thread. This works best in conjunction with a thread pool design. 469 | * 470 | * If, however, you need to move the socket to a separate thread at a later time, this 471 | * method may be used to accomplish the task. 472 | * 473 | * This method must be called from the thread/runloop the socket is currently running on. 474 | * 475 | * Note: After calling this method, all further method calls to this object should be done from the given runloop. 476 | * Also, all delegate calls will be sent on the given runloop. 477 | **/ 478 | - (BOOL)moveToRunLoop:(NSRunLoop *)runLoop; 479 | 480 | /** 481 | * Allows you to configure which run loop modes the socket uses. 482 | * The default set of run loop modes is NSDefaultRunLoopMode. 483 | * 484 | * If you'd like your socket to continue operation during other modes, you may want to add modes such as 485 | * NSModalPanelRunLoopMode or NSEventTrackingRunLoopMode. Or you may simply want to use NSRunLoopCommonModes. 486 | * 487 | * Accepted sockets will automatically inherit the same run loop modes as the listening socket. 488 | * 489 | * Note: NSRunLoopCommonModes is defined in 10.5. For previous versions one can use kCFRunLoopCommonModes. 490 | **/ 491 | - (BOOL)setRunLoopModes:(NSArray *)runLoopModes; 492 | 493 | /** 494 | * Returns the current run loop modes the AsyncSocket instance is operating in. 495 | * The default set of run loop modes is NSDefaultRunLoopMode. 496 | **/ 497 | - (NSArray *)runLoopModes; 498 | 499 | /** 500 | * In the event of an error, this method may be called during onSocket:willDisconnectWithError: to read 501 | * any data that's left on the socket. 502 | **/ 503 | - (NSData *)unreadData; 504 | 505 | /* A few common line separators, for use with the readDataToData:... methods. */ 506 | + (NSData *)CRLFData; // 0x0D0A 507 | + (NSData *)CRData; // 0x0D 508 | + (NSData *)LFData; // 0x0A 509 | + (NSData *)ZeroData; // 0x00 510 | 511 | @end 512 | -------------------------------------------------------------------------------- /src/Vendor/AsyncSocket/AsyncUdpSocket.h: -------------------------------------------------------------------------------- 1 | // 2 | // AsyncUdpSocket.h 3 | // 4 | // This class is in the public domain. 5 | // Originally created by Robbie Hanson on Wed Oct 01 2008. 6 | // Updated and maintained by Deusty Designs and the Mac development community. 7 | // 8 | // http://code.google.com/p/cocoaasyncsocket/ 9 | // 10 | 11 | #import 12 | 13 | @class AsyncSendPacket; 14 | @class AsyncReceivePacket; 15 | 16 | extern NSString *const AsyncUdpSocketException; 17 | extern NSString *const AsyncUdpSocketErrorDomain; 18 | 19 | enum AsyncUdpSocketError 20 | { 21 | AsyncUdpSocketCFSocketError = kCFSocketError, // From CFSocketError enum 22 | AsyncUdpSocketNoError = 0, // Never used 23 | AsyncUdpSocketBadParameter, // Used if given a bad parameter (such as an improper address) 24 | AsyncUdpSocketIPv4Unavailable, // Used if you bind/connect using IPv6 only 25 | AsyncUdpSocketIPv6Unavailable, // Used if you bind/connect using IPv4 only (or iPhone) 26 | AsyncUdpSocketSendTimeoutError, 27 | AsyncUdpSocketReceiveTimeoutError 28 | }; 29 | typedef enum AsyncUdpSocketError AsyncUdpSocketError; 30 | 31 | @interface AsyncUdpSocket : NSObject 32 | { 33 | CFSocketRef theSocket4; // IPv4 socket 34 | CFSocketRef theSocket6; // IPv6 socket 35 | 36 | CFRunLoopSourceRef theSource4; // For theSocket4 37 | CFRunLoopSourceRef theSource6; // For theSocket6 38 | CFRunLoopRef theRunLoop; 39 | CFSocketContext theContext; 40 | NSArray *theRunLoopModes; 41 | 42 | NSMutableArray *theSendQueue; 43 | AsyncSendPacket *theCurrentSend; 44 | NSTimer *theSendTimer; 45 | 46 | NSMutableArray *theReceiveQueue; 47 | AsyncReceivePacket *theCurrentReceive; 48 | NSTimer *theReceiveTimer; 49 | 50 | id theDelegate; 51 | UInt16 theFlags; 52 | 53 | long theUserData; 54 | 55 | NSString *cachedLocalHost; 56 | UInt16 cachedLocalPort; 57 | 58 | NSString *cachedConnectedHost; 59 | UInt16 cachedConnectedPort; 60 | 61 | UInt32 maxReceiveBufferSize; 62 | } 63 | 64 | /** 65 | * Creates new instances of AsyncUdpSocket. 66 | **/ 67 | - (id)init; 68 | - (id)initWithDelegate:(id)delegate; 69 | - (id)initWithDelegate:(id)delegate userData:(long)userData; 70 | 71 | /** 72 | * Creates new instances of AsyncUdpSocket that support only IPv4 or IPv6. 73 | * The other init methods will support both, unless specifically binded or connected to one protocol. 74 | * If you know you'll only be using one protocol, these init methods may be a bit more efficient. 75 | **/ 76 | - (id)initIPv4; 77 | - (id)initIPv6; 78 | 79 | - (id)delegate; 80 | - (void)setDelegate:(id)delegate; 81 | 82 | - (long)userData; 83 | - (void)setUserData:(long)userData; 84 | 85 | /** 86 | * Returns the local address info for the socket. 87 | * 88 | * Note: Address info may not be available until after the socket has been bind'ed, 89 | * or until after data has been sent. 90 | **/ 91 | - (NSString *)localHost; 92 | - (UInt16)localPort; 93 | 94 | /** 95 | * Returns the remote address info for the socket. 96 | * 97 | * Note: Since UDP is connectionless by design, connected address info 98 | * will not be available unless the socket is explicitly connected to a remote host/port 99 | **/ 100 | - (NSString *)connectedHost; 101 | - (UInt16)connectedPort; 102 | 103 | /** 104 | * Returns whether or not this socket has been connected to a single host. 105 | * By design, UDP is a connectionless protocol, and connecting is not needed. 106 | * If connected, the socket will only be able to send/receive data to/from the connected host. 107 | **/ 108 | - (BOOL)isConnected; 109 | 110 | /** 111 | * Returns whether or not this socket has been closed. 112 | * The only way a socket can be closed is if you explicitly call one of the close methods. 113 | **/ 114 | - (BOOL)isClosed; 115 | 116 | /** 117 | * Returns whether or not this socket supports IPv4. 118 | * By default this will be true, unless the socket is specifically initialized as IPv6 only, 119 | * or is binded or connected to an IPv6 address. 120 | **/ 121 | - (BOOL)isIPv4; 122 | 123 | /** 124 | * Returns whether or not this socket supports IPv6. 125 | * By default this will be true, unless the socket is specifically initialized as IPv4 only, 126 | * or is binded or connected to an IPv4 address. 127 | * 128 | * This method will also return false on platforms that do not support IPv6. 129 | * Note: The iPhone does not currently support IPv6. 130 | **/ 131 | - (BOOL)isIPv6; 132 | 133 | /** 134 | * Returns the mtu of the socket. 135 | * If unknown, returns zero. 136 | * 137 | * Sending data larger than this may result in an error. 138 | * This is an advanced topic, and one should understand the wide range of mtu's on networks and the internet. 139 | * Therefore this method is only for reference and may be of little use in many situations. 140 | **/ 141 | - (unsigned int)maximumTransmissionUnit; 142 | 143 | /** 144 | * Binds the UDP socket to the given port and optional address. 145 | * Binding should be done for server sockets that receive data prior to sending it. 146 | * Client sockets can skip binding, 147 | * as the OS will automatically assign the socket an available port when it starts sending data. 148 | * 149 | * You cannot bind a socket after its been connected. 150 | * You can only bind a socket once. 151 | * You can still connect a socket (if desired) after binding. 152 | * 153 | * On success, returns YES. 154 | * Otherwise returns NO, and sets errPtr. If you don't care about the error, you can pass nil for errPtr. 155 | **/ 156 | - (BOOL)bindToPort:(UInt16)port error:(NSError **)errPtr; 157 | - (BOOL)bindToAddress:(NSString *)localAddr port:(UInt16)port error:(NSError **)errPtr; 158 | 159 | /** 160 | * Connects the UDP socket to the given host and port. 161 | * By design, UDP is a connectionless protocol, and connecting is not needed. 162 | * 163 | * Choosing to connect to a specific host/port has the following effect: 164 | * - You will only be able to send data to the connected host/port. 165 | * - You will only be able to receive data from the connected host/port. 166 | * - You will receive ICMP messages that come from the connected host/port, such as "connection refused". 167 | * 168 | * Connecting a UDP socket does not result in any communication on the socket. 169 | * It simply changes the internal state of the socket. 170 | * 171 | * You cannot bind a socket after its been connected. 172 | * You can only connect a socket once. 173 | * 174 | * On success, returns YES. 175 | * Otherwise returns NO, and sets errPtr. If you don't care about the error, you can pass nil for errPtr. 176 | **/ 177 | - (BOOL)connectToHost:(NSString *)host onPort:(UInt16)port error:(NSError **)errPtr; 178 | - (BOOL)connectToAddress:(NSData *)remoteAddr error:(NSError **)errPtr; 179 | 180 | /** 181 | * Join multicast group 182 | * 183 | * Group should be an IP address (eg @"225.228.0.1") 184 | **/ 185 | - (BOOL)joinMulticastGroup:(NSString *)group error:(NSError **)errPtr; 186 | - (BOOL)joinMulticastGroup:(NSString *)group withAddress:(NSString *)interface error:(NSError **)errPtr; 187 | 188 | /** 189 | * By default, the underlying socket in the OS will not allow you to send broadcast messages. 190 | * In order to send broadcast messages, you need to enable this functionality in the socket. 191 | * 192 | * A broadcast is a UDP message to addresses like "192.168.255.255" or "255.255.255.255" that is 193 | * delivered to every host on the network. 194 | * The reason this is generally disabled by default is to prevent 195 | * accidental broadcast messages from flooding the network. 196 | **/ 197 | - (BOOL)enableBroadcast:(BOOL)flag error:(NSError **)errPtr; 198 | 199 | /** 200 | * Asynchronously sends the given data, with the given timeout and tag. 201 | * 202 | * This method may only be used with a connected socket. 203 | * 204 | * If data is nil or zero-length, this method does nothing and immediately returns NO. 205 | * If the socket is not connected, this method does nothing and immediately returns NO. 206 | **/ 207 | - (BOOL)sendData:(NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag; 208 | 209 | /** 210 | * Asynchronously sends the given data, with the given timeout and tag, to the given host and port. 211 | * 212 | * This method cannot be used with a connected socket. 213 | * 214 | * If data is nil or zero-length, this method does nothing and immediately returns NO. 215 | * If the socket is connected, this method does nothing and immediately returns NO. 216 | * If unable to resolve host to a valid IPv4 or IPv6 address, this method returns NO. 217 | **/ 218 | - (BOOL)sendData:(NSData *)data toHost:(NSString *)host port:(UInt16)port withTimeout:(NSTimeInterval)timeout tag:(long)tag; 219 | 220 | /** 221 | * Asynchronously sends the given data, with the given timeout and tag, to the given address. 222 | * 223 | * This method cannot be used with a connected socket. 224 | * 225 | * If data is nil or zero-length, this method does nothing and immediately returns NO. 226 | * If the socket is connected, this method does nothing and immediately returns NO. 227 | **/ 228 | - (BOOL)sendData:(NSData *)data toAddress:(NSData *)remoteAddr withTimeout:(NSTimeInterval)timeout tag:(long)tag; 229 | 230 | /** 231 | * Asynchronously receives a single datagram packet. 232 | * 233 | * If the receive succeeds, the onUdpSocket:didReceiveData:fromHost:port:tag delegate method will be called. 234 | * Otherwise, a timeout will occur, and the onUdpSocket:didNotReceiveDataWithTag: delegate method will be called. 235 | **/ 236 | - (void)receiveWithTimeout:(NSTimeInterval)timeout tag:(long)tag; 237 | 238 | /** 239 | * Closes the socket immediately. Any pending send or receive operations are dropped. 240 | **/ 241 | - (void)close; 242 | 243 | /** 244 | * Closes after all pending send operations have completed. 245 | * After calling this, the sendData: and receive: methods will do nothing. 246 | * In other words, you won't be able to add any more send or receive operations to the queue. 247 | * The socket will close even if there are still pending receive operations. 248 | **/ 249 | - (void)closeAfterSending; 250 | 251 | /** 252 | * Closes after all pending receive operations have completed. 253 | * After calling this, the sendData: and receive: methods will do nothing. 254 | * In other words, you won't be able to add any more send or receive operations to the queue. 255 | * The socket will close even if there are still pending send operations. 256 | **/ 257 | - (void)closeAfterReceiving; 258 | 259 | /** 260 | * Closes after all pending send and receive operations have completed. 261 | * After calling this, the sendData: and receive: methods will do nothing. 262 | * In other words, you won't be able to add any more send or receive operations to the queue. 263 | **/ 264 | - (void)closeAfterSendingAndReceiving; 265 | 266 | /** 267 | * Gets/Sets the maximum size of the buffer that will be allocated for receive operations. 268 | * The default size is 9216 bytes. 269 | * 270 | * The theoretical maximum size of any IPv4 UDP packet is UINT16_MAX = 65535. 271 | * The theoretical maximum size of any IPv6 UDP packet is UINT32_MAX = 4294967295. 272 | * 273 | * In practice, however, the size of UDP packets will be much smaller. 274 | * Indeed most protocols will send and receive packets of only a few bytes, 275 | * or will set a limit on the size of packets to prevent fragmentation in the IP layer. 276 | * 277 | * If you set the buffer size too small, the sockets API in the OS will silently discard 278 | * any extra data, and you will not be notified of the error. 279 | **/ 280 | - (UInt32)maxReceiveBufferSize; 281 | - (void)setMaxReceiveBufferSize:(UInt32)max; 282 | 283 | /** 284 | * When you create an AsyncUdpSocket, it is added to the runloop of the current thread. 285 | * So it is easiest to simply create the socket on the thread you intend to use it. 286 | * 287 | * If, however, you need to move the socket to a separate thread at a later time, this 288 | * method may be used to accomplish the task. 289 | * 290 | * This method must be called from the thread/runloop the socket is currently running on. 291 | * 292 | * Note: After calling this method, all further method calls to this object should be done from the given runloop. 293 | * Also, all delegate calls will be sent on the given runloop. 294 | **/ 295 | - (BOOL)moveToRunLoop:(NSRunLoop *)runLoop; 296 | 297 | /** 298 | * Allows you to configure which run loop modes the socket uses. 299 | * The default set of run loop modes is NSDefaultRunLoopMode. 300 | * 301 | * If you'd like your socket to continue operation during other modes, you may want to add modes such as 302 | * NSModalPanelRunLoopMode or NSEventTrackingRunLoopMode. Or you may simply want to use NSRunLoopCommonModes. 303 | * 304 | * Note: NSRunLoopCommonModes is defined in 10.5. For previous versions one can use kCFRunLoopCommonModes. 305 | **/ 306 | - (BOOL)setRunLoopModes:(NSArray *)runLoopModes; 307 | 308 | /** 309 | * Returns the current run loop modes the AsyncSocket instance is operating in. 310 | * The default set of run loop modes is NSDefaultRunLoopMode. 311 | **/ 312 | - (NSArray *)runLoopModes; 313 | 314 | @end 315 | 316 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 317 | #pragma mark - 318 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 319 | 320 | @interface NSObject (AsyncUdpSocketDelegate) 321 | 322 | /** 323 | * Called when the datagram with the given tag has been sent. 324 | **/ 325 | - (void)onUdpSocket:(AsyncUdpSocket *)sock didSendDataWithTag:(long)tag; 326 | 327 | /** 328 | * Called if an error occurs while trying to send a datagram. 329 | * This could be due to a timeout, or something more serious such as the data being too large to fit in a sigle packet. 330 | **/ 331 | - (void)onUdpSocket:(AsyncUdpSocket *)sock didNotSendDataWithTag:(long)tag dueToError:(NSError *)error; 332 | 333 | /** 334 | * Called when the socket has received the requested datagram. 335 | * 336 | * Due to the nature of UDP, you may occasionally receive undesired packets. 337 | * These may be rogue UDP packets from unknown hosts, 338 | * or they may be delayed packets arriving after retransmissions have already occurred. 339 | * It's important these packets are properly ignored, while not interfering with the flow of your implementation. 340 | * As an aid, this delegate method has a boolean return value. 341 | * If you ever need to ignore a received packet, simply return NO, 342 | * and AsyncUdpSocket will continue as if the packet never arrived. 343 | * That is, the original receive request will still be queued, and will still timeout as usual if a timeout was set. 344 | * For example, say you requested to receive data, and you set a timeout of 500 milliseconds, using a tag of 15. 345 | * If rogue data arrives after 250 milliseconds, this delegate method would be invoked, and you could simply return NO. 346 | * If the expected data then arrives within the next 250 milliseconds, 347 | * this delegate method will be invoked, with a tag of 15, just as if the rogue data never appeared. 348 | * 349 | * Under normal circumstances, you simply return YES from this method. 350 | **/ 351 | - (BOOL)onUdpSocket:(AsyncUdpSocket *)sock didReceiveData:(NSData *)data withTag:(long)tag fromHost:(NSString *)host port:(UInt16)port; 352 | 353 | /** 354 | * Called if an error occurs while trying to receive a requested datagram. 355 | * This is generally due to a timeout, but could potentially be something else if some kind of OS error occurred. 356 | **/ 357 | - (void)onUdpSocket:(AsyncUdpSocket *)sock didNotReceiveDataWithTag:(long)tag dueToError:(NSError *)error; 358 | 359 | /** 360 | * Called when the socket is closed. 361 | * A socket is only closed if you explicitly call one of the close methods. 362 | **/ 363 | - (void)onUdpSocketDidClose:(AsyncUdpSocket *)sock; 364 | 365 | @end 366 | -------------------------------------------------------------------------------- /src/Vendor/AsyncSocket/changes.txt: -------------------------------------------------------------------------------- 1 | The last version of AsyncSocket from Dustin Voss was version 4.3 released on 2005-11-23. This document lists the bug fixes provided by Deusty Designs, prior to the creation of the Google Code project. 2 | 3 | CHANGES IN VERSION 4.3.1: 4 | 5 | Bugfix: 6 | If user called acceptOnPort:0, then the OS would automatically pick a port for you. 7 | This is what is supposed to happen, except that it would pick a different port for IPv4 and IPv6 8 | Added code to make sure both protocols are listening on the same port 9 | 10 | Added comments in many places 11 | 12 | Altered bits of code to match Apple's coding style guidelines 13 | 14 | Renamed method "attachAcceptSockets" to "attachSocketsToRunLoop:error:" 15 | 16 | 17 | 18 | 19 | CHANGES IN VERSION 4.3.2 20 | 21 | Removed polling - it's not needed 22 | 23 | Added another delegate method: onSocket:didReadPartialDataOfLength:tag: 24 | Often, when using the AsyncSocket class, it was important to display a progress bar to the user. 25 | This was possible using Timers, and calling progressOfRead, but it wasn't the easiest solution. 26 | This delegate method will allow for automatic notification when using readToLength: or readToData: 27 | 28 | 29 | 30 | 31 | CHANGES IN VERSION 4.3.3 32 | 33 | Bugfix: 34 | The methods connectedHost, connectedPort, localHost, and localPort all assumed IPv4 connection. 35 | In other words they all assumed theSocket was valid, causing a crash when the OS connected via IPv6. 36 | Updated all methods to properly check either theSocket or theSocket6. 37 | 38 | Bugfix: 39 | In the doStreamOpen method, there was an assumption that IPv4 was used and thus a valid theSocket variable. 40 | This was not always the case, causing this to fail: 41 | CFSocketCopyPeerAddress(theSocket) 42 | Fixed the problem by simply using the connectedHost and connectedPort methods. 43 | 44 | Tweak: 45 | Added safety check in addressPort: method: 46 | if (cfaddr == NULL) return 0; 47 | 48 | Tweak: 49 | The kCFStreamPropertyShouldCloseNativeSocket was previously getting set in the configureStreamsAndReturnError: method. 50 | This may have been OK, but it would have caused a problem if the following sequence occurred: 51 | A socket was accepted and doAcceptWithSocket: method was called, 52 | This method then encoutered an error while attaching the streams to the run loop. 53 | If this sequence happened, the BSD socket would not have been closed. 54 | So I moved this into the createStreams... methods. 55 | 56 | 57 | 58 | 59 | CHANGES IN VERSION 4.3.4 60 | 61 | Bugfix: 62 | In doReadTimeout: the code properly calls endCurrentWrite and then closes with an error. 63 | In doWriteTimeout: the code was calling completeCurrentWrite and then closes with an error. 64 | This resulted in the delegate being told that his write completed (when it didn't) 65 | immediately prior to disconnecting with an error. 66 | 67 | 68 | 69 | 70 | CHANGES IN VERSION 4.3.5 71 | 72 | Added support for accepting on IPv6 address. 73 | 74 | Bugfix: 75 | In acceptOnAddress, changed dataWithBytesNoCopy to dataWithBytes. 76 | This was needed because the bytes were about to go out of scope. 77 | 78 | Bugfix: 79 | Added return statement to doStreamOpen after closewithError call. 80 | This was needed or else the didConnect delegate could potentially get called 81 | immediately after willCloseWithError and didClose. 82 | 83 | Bugfix: 84 | We were receiving several reports of crashes in AsyncSocket. 85 | The problem seemed to be that, in specific circumstances, 86 | the readStream callback and/or writeStream callback would be invoked AFTER 87 | the readStream and writeStream were closed. 88 | This isn't supposed to happen, however we did find evidence that it was an issue several years ago. 89 | It was assumed that the problem has since been fixed. 90 | Perhaps the problem still exists, but only in very rare cases which we just happened to be encountering. 91 | In any case, we used the same precautions that were used previously. 92 | In the close methods, we specifically unregister for callbacks now. 93 | 94 | 95 | 96 | 97 | There have been MANY more bug fixes and changes. Please consult the google code changes list: 98 | http://code.google.com/p/cocoaasyncsocket/source/list -------------------------------------------------------------------------------- /src/ZTFakeLocationManager.m: -------------------------------------------------------------------------------- 1 | #import "ZTFakeLocationManager.h" 2 | 3 | #define UPDATE_INTERVAL 1.0 4 | 5 | @interface ZTFakeLocationManager(Private) 6 | -(void)_reachWaypoint; 7 | @end 8 | 9 | @implementation ZTFakeLocationManager 10 | 11 | -(id)initWithWaypoints:(NSArray*)waypoints { 12 | if (self = [super init]) { 13 | NSAssert([waypoints count] > 0, @"Tried creating ZTFakeLocationManager with no waypoints"); 14 | 15 | _currentWaypoint = 0; 16 | _waypoints = [waypoints retain]; 17 | } 18 | return self; 19 | } 20 | 21 | +(id)fakeLocationManagerWithContentsOfFile:(NSString*)path { 22 | NSMutableArray* waypoints = [[[NSMutableArray alloc] init] autorelease]; 23 | NSString *resource = [[NSBundle mainBundle] pathForResource:path ofType:nil]; 24 | 25 | NSAssert1(resource, @"Waypoints file %@ not found",path); 26 | 27 | NSString *contents = [NSString stringWithContentsOfFile:resource usedEncoding:NULL error:NULL]; 28 | NSArray *lines = [contents componentsSeparatedByString:@"\n"]; 29 | 30 | for (NSString* line in lines) { 31 | NSArray *latLong = [line componentsSeparatedByString:@","]; 32 | 33 | if ([latLong count] != 2) break; 34 | 35 | CLLocationDegrees lat = [[latLong objectAtIndex:0] doubleValue]; 36 | CLLocationDegrees lon = [[latLong objectAtIndex:1] doubleValue]; 37 | 38 | CLLocation* location = [[[CLLocation alloc] initWithLatitude:lat longitude:lon] autorelease]; 39 | [waypoints addObject:location]; 40 | } 41 | return [[[ZTFakeLocationManager alloc] initWithWaypoints:waypoints] autorelease]; 42 | } 43 | 44 | -(void)startUpdatingLocation { 45 | [self _reachWaypoint]; 46 | if ([_waypoints count]>1) { 47 | _clock = [NSTimer scheduledTimerWithTimeInterval:UPDATE_INTERVAL target:self selector:@selector(_reachWaypoint) userInfo:nil repeats:YES]; 48 | } 49 | } 50 | 51 | -(void)stopUpdatingLocation { 52 | if (_clock) { 53 | [_clock invalidate]; 54 | _clock = nil; 55 | } 56 | } 57 | 58 | -(void)_reachWaypoint { 59 | CLLocation* newLocation = [_waypoints objectAtIndex:_currentWaypoint]; 60 | _currentWaypoint++; 61 | if (_currentWaypoint >= [_waypoints count]) _currentWaypoint = 0; 62 | [self.delegate locationManager:self didUpdateToLocation:newLocation fromLocation:_lastLocation]; 63 | _lastLocation = newLocation; 64 | } 65 | 66 | -(void)dealloc { 67 | [self stopUpdatingLocation]; 68 | [_waypoints release]; 69 | [super dealloc]; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /src/ZTWebSocket.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZTWebSocket.m 3 | // Zimt 4 | // 5 | // Created by Esad Hajdarevic on 2/14/10. 6 | // Copyright 2010 OpenResearch Software Development OG. All rights reserved. 7 | // 8 | 9 | #import "ZTWebSocket.h" 10 | #import "AsyncSocket.h" 11 | 12 | 13 | NSString* const ZTWebSocketErrorDomain = @"ZTWebSocketErrorDomain"; 14 | NSString* const ZTWebSocketException = @"ZTWebSocketException"; 15 | 16 | enum { 17 | ZTWebSocketTagHandshake = 0, 18 | ZTWebSocketTagMessage = 1 19 | }; 20 | 21 | @implementation ZTWebSocket 22 | 23 | @synthesize delegate, url, origin, connected, runLoopModes; 24 | 25 | #pragma mark Initializers 26 | 27 | + (id)webSocketWithURLString:(NSString*)urlString delegate:(id)aDelegate { 28 | return [[[ZTWebSocket alloc] initWithURLString:urlString delegate:aDelegate] autorelease]; 29 | } 30 | 31 | -(id)initWithURLString:(NSString *)urlString delegate:(id)aDelegate { 32 | if (self=[super init]) { 33 | self.delegate = aDelegate; 34 | url = [[NSURL URLWithString:urlString] retain]; 35 | if (![url.scheme isEqualToString:@"ws"]) { 36 | [NSException raise:ZTWebSocketException format:[NSString stringWithFormat:@"Unsupported protocol %@",url.scheme]]; 37 | } 38 | socket = [[AsyncSocket alloc] initWithDelegate:self]; 39 | self.runLoopModes = [NSArray arrayWithObjects:NSRunLoopCommonModes, nil]; 40 | } 41 | return self; 42 | } 43 | 44 | #pragma mark Delegate dispatch methods 45 | 46 | -(void)_dispatchFailure:(NSNumber*)code { 47 | if(delegate && [delegate respondsToSelector:@selector(webSocket:didFailWithError:)]) { 48 | [delegate webSocket:self didFailWithError:[NSError errorWithDomain:ZTWebSocketErrorDomain code:[code intValue] userInfo:nil]]; 49 | } 50 | } 51 | 52 | -(void)_dispatchClosed { 53 | if (delegate && [delegate respondsToSelector:@selector(webSocketDidClose:)]) { 54 | [delegate webSocketDidClose:self]; 55 | } 56 | } 57 | 58 | -(void)_dispatchOpened { 59 | if (delegate && [delegate respondsToSelector:@selector(webSocketDidOpen:)]) { 60 | [delegate webSocketDidOpen:self]; 61 | } 62 | } 63 | 64 | -(void)_dispatchMessageReceived:(NSString*)message { 65 | if (delegate && [delegate respondsToSelector:@selector(webSocket:didReceiveMessage:)]) { 66 | [delegate webSocket:self didReceiveMessage:message]; 67 | } 68 | } 69 | 70 | -(void)_dispatchMessageSent { 71 | if (delegate && [delegate respondsToSelector:@selector(webSocketDidSendMessage:)]) { 72 | [delegate webSocketDidSendMessage:self]; 73 | } 74 | } 75 | 76 | #pragma mark Private 77 | 78 | -(void)_readNextMessage { 79 | [socket readDataToData:[NSData dataWithBytes:"\xFF" length:1] withTimeout:-1 tag:ZTWebSocketTagMessage]; 80 | } 81 | 82 | #pragma mark Public interface 83 | 84 | -(void)close { 85 | [socket disconnectAfterReadingAndWriting]; 86 | } 87 | 88 | -(void)open { 89 | if (!connected) { 90 | [socket connectToHost:url.host onPort:[url.port intValue] withTimeout:5 error:nil]; 91 | if (runLoopModes) [socket setRunLoopModes:runLoopModes]; 92 | } 93 | } 94 | 95 | -(void)send:(NSString*)message { 96 | NSMutableData* data = [NSMutableData data]; 97 | [data appendBytes:"\x00" length:1]; 98 | [data appendData:[message dataUsingEncoding:NSUTF8StringEncoding]]; 99 | [data appendBytes:"\xFF" length:1]; 100 | [socket writeData:data withTimeout:-1 tag:ZTWebSocketTagMessage]; 101 | } 102 | 103 | #pragma mark AsyncSocket delegate methods 104 | 105 | -(void)onSocketDidDisconnect:(AsyncSocket *)sock { 106 | connected = NO; 107 | } 108 | 109 | -(void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err { 110 | if (!connected) { 111 | [self _dispatchFailure:[NSNumber numberWithInt:ZTWebSocketErrorConnectionFailed]]; 112 | } else { 113 | [self _dispatchClosed]; 114 | } 115 | } 116 | 117 | - (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port { 118 | NSString* requestOrigin = self.origin; 119 | if (!requestOrigin) requestOrigin = [NSString stringWithFormat:@"http://%@",url.host]; 120 | 121 | NSString *requestPath = url.path; 122 | if (url.query) { 123 | requestPath = [requestPath stringByAppendingFormat:@"?%@", url.query]; 124 | } 125 | NSString* getRequest = [NSString stringWithFormat:@"GET %@ HTTP/1.1\r\n" 126 | "Upgrade: WebSocket\r\n" 127 | "Connection: Upgrade\r\n" 128 | "Host: %@\r\n" 129 | "Origin: %@\r\n" 130 | "\r\n", 131 | requestPath,url.host,requestOrigin]; 132 | [socket writeData:[getRequest dataUsingEncoding:NSASCIIStringEncoding] withTimeout:-1 tag:ZTWebSocketTagHandshake]; 133 | } 134 | 135 | -(void)onSocket:(AsyncSocket *)sock didWriteDataWithTag:(long)tag { 136 | if (tag == ZTWebSocketTagHandshake) { 137 | [sock readDataToData:[@"\r\n\r\n" dataUsingEncoding:NSASCIIStringEncoding] withTimeout:-1 tag:ZTWebSocketTagHandshake]; 138 | } else if (tag == ZTWebSocketTagMessage) { 139 | [self _dispatchMessageSent]; 140 | } 141 | } 142 | 143 | -(void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { 144 | if (tag == ZTWebSocketTagHandshake) { 145 | NSString* response = [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease]; 146 | if ([response hasPrefix:@"HTTP/1.1 101 Web Socket Protocol Handshake\r\nUpgrade: WebSocket\r\nConnection: Upgrade\r\n"]) { 147 | connected = YES; 148 | [self _dispatchOpened]; 149 | 150 | [self _readNextMessage]; 151 | } else { 152 | [self _dispatchFailure:[NSNumber numberWithInt:ZTWebSocketErrorHandshakeFailed]]; 153 | } 154 | } else if (tag == ZTWebSocketTagMessage) { 155 | char firstByte = 0xFF; 156 | [data getBytes:&firstByte length:1]; 157 | if (firstByte != 0x00) return; // Discard message 158 | NSString* message = [[[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(1, [data length]-2)] encoding:NSUTF8StringEncoding] autorelease]; 159 | 160 | [self _dispatchMessageReceived:message]; 161 | [self _readNextMessage]; 162 | } 163 | } 164 | 165 | #pragma mark Destructor 166 | 167 | -(void)dealloc { 168 | socket.delegate = nil; 169 | [socket disconnect]; 170 | [socket release]; 171 | [runLoopModes release]; 172 | [url release]; 173 | [super dealloc]; 174 | } 175 | 176 | @end 177 | 178 | -------------------------------------------------------------------------------- /src/Zimt.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 45; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | AA747D9F0F9514B9006C5449 /* Zimt_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* Zimt_Prefix.pch */; }; 11 | AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; 12 | C779972D112758C500B197AE /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C779972C112758C500B197AE /* CoreLocation.framework */; }; 13 | C779986F112768BA00B197AE /* ZTWebSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = C779986D112768BA00B197AE /* ZTWebSocket.m */; }; 14 | C77999CB1128EE0200B197AE /* ZTWebSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = C77999CA1128EE0200B197AE /* ZTWebSocket.h */; }; 15 | C7799AC41128F28100B197AE /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C7799A1F1128F03600B197AE /* CFNetwork.framework */; }; 16 | C7BF061111273DE3000F2DF4 /* ZTLog.h in Headers */ = {isa = PBXBuildFile; fileRef = C7BF060F11273DE3000F2DF4 /* ZTLog.h */; }; 17 | C7BF061211273DE3000F2DF4 /* Zimt.h in Headers */ = {isa = PBXBuildFile; fileRef = C7BF061011273DE3000F2DF4 /* Zimt.h */; }; 18 | C7BF06A011274609000F2DF4 /* ZTFakeLocationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C7BF069E11274609000F2DF4 /* ZTFakeLocationManager.m */; }; 19 | C7BF0822112750B1000F2DF4 /* ZTFakeLocationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C7BF0821112750B1000F2DF4 /* ZTFakeLocationManager.h */; }; 20 | C7CBF677113E9CDE00546ABF /* AsyncSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = C7CBF676113E9CDE00546ABF /* AsyncSocket.h */; }; 21 | C7CBF6BE113E9D2E00546ABF /* AsyncSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = C7CBF6BB113E9D2E00546ABF /* AsyncSocket.m */; }; 22 | C7CBF6BF113E9D2E00546ABF /* AsyncUdpSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = C7CBF6BC113E9D2E00546ABF /* AsyncUdpSocket.m */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXFileReference section */ 26 | AA747D9E0F9514B9006C5449 /* Zimt_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Zimt_Prefix.pch; sourceTree = SOURCE_ROOT; }; 27 | AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 28 | C779972C112758C500B197AE /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; 29 | C779986D112768BA00B197AE /* ZTWebSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZTWebSocket.m; sourceTree = ""; }; 30 | C77999CA1128EE0200B197AE /* ZTWebSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ZTWebSocket.h; path = Zimt/ZTWebSocket.h; sourceTree = ""; }; 31 | C7799A1F1128F03600B197AE /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; 32 | C7BF060F11273DE3000F2DF4 /* ZTLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ZTLog.h; path = Zimt/ZTLog.h; sourceTree = ""; }; 33 | C7BF061011273DE3000F2DF4 /* Zimt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Zimt.h; path = Zimt/Zimt.h; sourceTree = ""; }; 34 | C7BF069E11274609000F2DF4 /* ZTFakeLocationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZTFakeLocationManager.m; sourceTree = ""; }; 35 | C7BF0821112750B1000F2DF4 /* ZTFakeLocationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ZTFakeLocationManager.h; path = Zimt/ZTFakeLocationManager.h; sourceTree = ""; }; 36 | C7CBF676113E9CDE00546ABF /* AsyncSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AsyncSocket.h; path = vendor/AsyncSocket/AsyncSocket.h; sourceTree = ""; }; 37 | C7CBF6BB113E9D2E00546ABF /* AsyncSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AsyncSocket.m; path = vendor/AsyncSocket/AsyncSocket.m; sourceTree = SOURCE_ROOT; }; 38 | C7CBF6BC113E9D2E00546ABF /* AsyncUdpSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AsyncUdpSocket.m; path = vendor/AsyncSocket/AsyncUdpSocket.m; sourceTree = SOURCE_ROOT; }; 39 | D2AAC07E0554694100DB518D /* libZimt.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libZimt.a; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | /* End PBXFileReference section */ 41 | 42 | /* Begin PBXFrameworksBuildPhase section */ 43 | D2AAC07C0554694100DB518D /* Frameworks */ = { 44 | isa = PBXFrameworksBuildPhase; 45 | buildActionMask = 2147483647; 46 | files = ( 47 | AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */, 48 | C779972D112758C500B197AE /* CoreLocation.framework in Frameworks */, 49 | C7799AC41128F28100B197AE /* CFNetwork.framework in Frameworks */, 50 | ); 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | /* End PBXFrameworksBuildPhase section */ 54 | 55 | /* Begin PBXGroup section */ 56 | 034768DFFF38A50411DB9C8B /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | D2AAC07E0554694100DB518D /* libZimt.a */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | 0867D691FE84028FC02AAC07 /* Zimt */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | C7CBF6B8113E9D1900546ABF /* Vendor */, 68 | 08FB77AEFE84172EC02AAC07 /* Core */, 69 | C7BF069B11274553000F2DF4 /* Fake Location Manager */, 70 | C779986B112768AC00B197AE /* Web Socket */, 71 | 32C88DFF0371C24200C91783 /* Other Sources */, 72 | 0867D69AFE84028FC02AAC07 /* Frameworks */, 73 | 034768DFFF38A50411DB9C8B /* Products */, 74 | ); 75 | name = Zimt; 76 | sourceTree = ""; 77 | }; 78 | 0867D69AFE84028FC02AAC07 /* Frameworks */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | AACBBE490F95108600F1A2B1 /* Foundation.framework */, 82 | C779972C112758C500B197AE /* CoreLocation.framework */, 83 | C7799A1F1128F03600B197AE /* CFNetwork.framework */, 84 | ); 85 | name = Frameworks; 86 | sourceTree = ""; 87 | }; 88 | 08FB77AEFE84172EC02AAC07 /* Core */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | C7BF060F11273DE3000F2DF4 /* ZTLog.h */, 92 | C7BF061011273DE3000F2DF4 /* Zimt.h */, 93 | ); 94 | name = Core; 95 | sourceTree = ""; 96 | }; 97 | 32C88DFF0371C24200C91783 /* Other Sources */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | AA747D9E0F9514B9006C5449 /* Zimt_Prefix.pch */, 101 | ); 102 | name = "Other Sources"; 103 | sourceTree = ""; 104 | }; 105 | C779986B112768AC00B197AE /* Web Socket */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | C77999CA1128EE0200B197AE /* ZTWebSocket.h */, 109 | C779986D112768BA00B197AE /* ZTWebSocket.m */, 110 | ); 111 | name = "Web Socket"; 112 | sourceTree = ""; 113 | }; 114 | C7BF069B11274553000F2DF4 /* Fake Location Manager */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | C7BF0821112750B1000F2DF4 /* ZTFakeLocationManager.h */, 118 | C7BF069E11274609000F2DF4 /* ZTFakeLocationManager.m */, 119 | ); 120 | name = "Fake Location Manager"; 121 | sourceTree = ""; 122 | }; 123 | C7CBF6B8113E9D1900546ABF /* Vendor */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | C7CBF6B9113E9D1E00546ABF /* AsyncSocket */, 127 | ); 128 | name = Vendor; 129 | sourceTree = ""; 130 | }; 131 | C7CBF6B9113E9D1E00546ABF /* AsyncSocket */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | C7CBF676113E9CDE00546ABF /* AsyncSocket.h */, 135 | C7CBF6BB113E9D2E00546ABF /* AsyncSocket.m */, 136 | C7CBF6BC113E9D2E00546ABF /* AsyncUdpSocket.m */, 137 | ); 138 | name = AsyncSocket; 139 | sourceTree = ""; 140 | }; 141 | /* End PBXGroup section */ 142 | 143 | /* Begin PBXHeadersBuildPhase section */ 144 | D2AAC07A0554694100DB518D /* Headers */ = { 145 | isa = PBXHeadersBuildPhase; 146 | buildActionMask = 2147483647; 147 | files = ( 148 | AA747D9F0F9514B9006C5449 /* Zimt_Prefix.pch in Headers */, 149 | C7BF061111273DE3000F2DF4 /* ZTLog.h in Headers */, 150 | C7BF061211273DE3000F2DF4 /* Zimt.h in Headers */, 151 | C7BF0822112750B1000F2DF4 /* ZTFakeLocationManager.h in Headers */, 152 | C77999CB1128EE0200B197AE /* ZTWebSocket.h in Headers */, 153 | C7CBF677113E9CDE00546ABF /* AsyncSocket.h in Headers */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXHeadersBuildPhase section */ 158 | 159 | /* Begin PBXNativeTarget section */ 160 | D2AAC07D0554694100DB518D /* Zimt */ = { 161 | isa = PBXNativeTarget; 162 | buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "Zimt" */; 163 | buildPhases = ( 164 | D2AAC07A0554694100DB518D /* Headers */, 165 | D2AAC07B0554694100DB518D /* Sources */, 166 | D2AAC07C0554694100DB518D /* Frameworks */, 167 | ); 168 | buildRules = ( 169 | ); 170 | dependencies = ( 171 | ); 172 | name = Zimt; 173 | productName = Zimt; 174 | productReference = D2AAC07E0554694100DB518D /* libZimt.a */; 175 | productType = "com.apple.product-type.library.static"; 176 | }; 177 | /* End PBXNativeTarget section */ 178 | 179 | /* Begin PBXProject section */ 180 | 0867D690FE84028FC02AAC07 /* Project object */ = { 181 | isa = PBXProject; 182 | buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "Zimt" */; 183 | compatibilityVersion = "Xcode 3.1"; 184 | hasScannedForEncodings = 1; 185 | mainGroup = 0867D691FE84028FC02AAC07 /* Zimt */; 186 | productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; 187 | projectDirPath = ""; 188 | projectRoot = ""; 189 | targets = ( 190 | D2AAC07D0554694100DB518D /* Zimt */, 191 | ); 192 | }; 193 | /* End PBXProject section */ 194 | 195 | /* Begin PBXSourcesBuildPhase section */ 196 | D2AAC07B0554694100DB518D /* Sources */ = { 197 | isa = PBXSourcesBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | C7BF06A011274609000F2DF4 /* ZTFakeLocationManager.m in Sources */, 201 | C779986F112768BA00B197AE /* ZTWebSocket.m in Sources */, 202 | C7CBF6BE113E9D2E00546ABF /* AsyncSocket.m in Sources */, 203 | C7CBF6BF113E9D2E00546ABF /* AsyncUdpSocket.m in Sources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXSourcesBuildPhase section */ 208 | 209 | /* Begin XCBuildConfiguration section */ 210 | 1DEB921F08733DC00010E9CD /* Debug */ = { 211 | isa = XCBuildConfiguration; 212 | buildSettings = { 213 | ALWAYS_SEARCH_USER_PATHS = NO; 214 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 215 | COPY_PHASE_STRIP = NO; 216 | DSTROOT = /tmp/Zimt.dst; 217 | GCC_DYNAMIC_NO_PIC = NO; 218 | GCC_ENABLE_FIX_AND_CONTINUE = YES; 219 | GCC_MODEL_TUNING = G5; 220 | GCC_OPTIMIZATION_LEVEL = 0; 221 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 222 | GCC_PREFIX_HEADER = Zimt_Prefix.pch; 223 | INSTALL_PATH = /usr/local/lib; 224 | PRODUCT_NAME = Zimt; 225 | }; 226 | name = Debug; 227 | }; 228 | 1DEB922008733DC00010E9CD /* Release */ = { 229 | isa = XCBuildConfiguration; 230 | buildSettings = { 231 | ALWAYS_SEARCH_USER_PATHS = NO; 232 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 233 | DSTROOT = /tmp/Zimt.dst; 234 | GCC_MODEL_TUNING = G5; 235 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 236 | GCC_PREFIX_HEADER = Zimt_Prefix.pch; 237 | INSTALL_PATH = /usr/local/lib; 238 | PRODUCT_NAME = Zimt; 239 | }; 240 | name = Release; 241 | }; 242 | 1DEB922308733DC00010E9CD /* Debug */ = { 243 | isa = XCBuildConfiguration; 244 | buildSettings = { 245 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 246 | GCC_C_LANGUAGE_STANDARD = c99; 247 | GCC_OPTIMIZATION_LEVEL = 0; 248 | GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; 249 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 250 | GCC_WARN_UNUSED_VARIABLE = YES; 251 | OTHER_LDFLAGS = "-ObjC"; 252 | PREBINDING = NO; 253 | SDKROOT = iphoneos3.0; 254 | }; 255 | name = Debug; 256 | }; 257 | 1DEB922408733DC00010E9CD /* Release */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 261 | GCC_C_LANGUAGE_STANDARD = c99; 262 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 263 | GCC_WARN_UNUSED_VARIABLE = YES; 264 | OTHER_LDFLAGS = "-ObjC"; 265 | PREBINDING = NO; 266 | SDKROOT = iphoneos3.0; 267 | }; 268 | name = Release; 269 | }; 270 | /* End XCBuildConfiguration section */ 271 | 272 | /* Begin XCConfigurationList section */ 273 | 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "Zimt" */ = { 274 | isa = XCConfigurationList; 275 | buildConfigurations = ( 276 | 1DEB921F08733DC00010E9CD /* Debug */, 277 | 1DEB922008733DC00010E9CD /* Release */, 278 | ); 279 | defaultConfigurationIsVisible = 0; 280 | defaultConfigurationName = Release; 281 | }; 282 | 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "Zimt" */ = { 283 | isa = XCConfigurationList; 284 | buildConfigurations = ( 285 | 1DEB922308733DC00010E9CD /* Debug */, 286 | 1DEB922408733DC00010E9CD /* Release */, 287 | ); 288 | defaultConfigurationIsVisible = 0; 289 | defaultConfigurationName = Release; 290 | }; 291 | /* End XCConfigurationList section */ 292 | }; 293 | rootObject = 0867D690FE84028FC02AAC07 /* Project object */; 294 | } 295 | -------------------------------------------------------------------------------- /src/Zimt/ZTFakeLocationManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface ZTFakeLocationManager : CLLocationManager { 5 | int _currentWaypoint; 6 | NSMutableArray *_waypoints; 7 | 8 | NSTimer* _clock; 9 | CLLocation* _lastLocation; 10 | } 11 | 12 | +(id)fakeLocationManagerWithContentsOfFile:(NSString*)path; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /src/Zimt/ZTLog.h: -------------------------------------------------------------------------------- 1 | #ifdef DEBUG 2 | #define ZTLog(xx, ...) NSLog(@"%s(%d): " xx, ((strrchr(__FILE__, '/') ? : __FILE__- 1) + 1), __LINE__, ##__VA_ARGS__) 3 | #else 4 | #define ZTLog(xx, ...) ((void)0) 5 | #endif 6 | 7 | #define ZTLogRect(r) ZTLog(@"%s x=%f, y=%f, w=%f, h=%f", #r, r.origin.x, r.origin.y, r.size.width, r.size.height) -------------------------------------------------------------------------------- /src/Zimt/ZTWebSocket.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZTWebSocket.h 3 | // Zimt 4 | // 5 | // Created by Esad Hajdarevic on 2/14/10. 6 | // Copyright 2010 OpenResearch Software Development OG. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class AsyncSocket; 12 | @class ZTWebSocket; 13 | 14 | @protocol ZTWebSocketDelegate 15 | @optional 16 | - (void)webSocket:(ZTWebSocket*)webSocket didFailWithError:(NSError*)error; 17 | - (void)webSocketDidOpen:(ZTWebSocket*)webSocket; 18 | - (void)webSocketDidClose:(ZTWebSocket*)webSocket; 19 | - (void)webSocket:(ZTWebSocket*)webSocket didReceiveMessage:(NSString*)message; 20 | - (void)webSocketDidSendMessage:(ZTWebSocket*)webSocket; 21 | @end 22 | 23 | @interface ZTWebSocket : NSObject { 24 | id delegate; 25 | NSURL* url; 26 | AsyncSocket* socket; 27 | BOOL connected; 28 | NSString* origin; 29 | 30 | NSArray* runLoopModes; 31 | } 32 | 33 | @property(nonatomic,assign) id delegate; 34 | @property(nonatomic,readonly) NSURL* url; 35 | @property(nonatomic,retain) NSString* origin; 36 | @property(nonatomic,readonly) BOOL connected; 37 | @property(nonatomic,retain) NSArray* runLoopModes; 38 | 39 | + (id)webSocketWithURLString:(NSString*)urlString delegate:(id)delegate; 40 | - (id)initWithURLString:(NSString*)urlString delegate:(id)delegate; 41 | 42 | - (void)open; 43 | - (void)close; 44 | - (void)send:(NSString*)message; 45 | 46 | @end 47 | 48 | enum { 49 | ZTWebSocketErrorConnectionFailed = 1, 50 | ZTWebSocketErrorHandshakeFailed = 2 51 | }; 52 | 53 | extern NSString *const ZTWebSocketException; 54 | extern NSString* const ZTWebSocketErrorDomain; 55 | -------------------------------------------------------------------------------- /src/Zimt/Zimt.h: -------------------------------------------------------------------------------- 1 | #import "Zimt/ZTLog.h" 2 | #import "Zimt/ZTFakeLocationManager.h" 3 | #import "Zimt/ZTWebSocket.h" 4 | -------------------------------------------------------------------------------- /src/Zimt_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'CocoaTouchStaticLibrary' target in the 'CocoaTouchStaticLibrary' project. 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | --------------------------------------------------------------------------------