Changeset 673
- Timestamp:
- 01/20/10 08:24:28 (8 weeks ago)
- Location:
- apps/iphone
- Files:
-
- 4 modified
-
my.tel/trunk/Classes/JSON/SBJSON.m (modified) (40 diffs)
-
my.tel/trunk/VIP.tel.xcodeproj/project.pbxproj (modified) (2 diffs)
-
superbook/trunk/DotTel_SDK/Classes/Reachability.h (modified) (1 diff)
-
superbook/trunk/DotTel_SDK/Classes/Reachability.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apps/iphone/my.tel/trunk/Classes/JSON/SBJSON.m
r130 r673 1 1 /* 2 Copyright (C) 2008 Stig Brautaset. All rights reserved.3 4 Redistribution and use in source and binary forms, with or without5 modification, are permitted provided that the following conditions are met:6 7 Redistributions of source code must retain the above copyright notice, this8 list of conditions and the following disclaimer.9 10 Redistributions in binary form must reproduce the above copyright notice,11 this list of conditions and the following disclaimer in the documentation12 and/or other materials provided with the distribution.13 14 Neither the name of the author nor the names of its contributors may be used15 to endorse or promote products derived from this software without specific16 prior written permission.17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28 */2 Copyright (C) 2008 Stig Brautaset. All rights reserved. 3 4 Redistribution and use in source and binary forms, with or without 5 modification, are permitted provided that the following conditions are met: 6 7 Redistributions of source code must retain the above copyright notice, this 8 list of conditions and the following disclaimer. 9 10 Redistributions in binary form must reproduce the above copyright notice, 11 this list of conditions and the following disclaimer in the documentation 12 and/or other materials provided with the distribution. 13 14 Neither the name of the author nor the names of its contributors may be used 15 to endorse or promote products derived from this software without specific 16 prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 29 30 30 #import "SBJSON.h" … … 169 169 if (![self appendArray:fragment into:json error:error]) 170 170 return NO; 171 171 172 172 } else if ([fragment isKindOfClass:[NSString class]]) { 173 173 if (![self appendString:fragment into:json error:error]) 174 174 return NO; 175 175 176 176 } else if ([fragment isKindOfClass:[NSNumber class]]) { 177 177 if ('c' == *[fragment objCType]) … … 179 179 else 180 180 [json appendString:[fragment stringValue]]; 181 181 182 182 } else if ([fragment isKindOfClass:[NSNull class]]) { 183 183 [json appendString:@"null"]; 184 184 185 185 } else { 186 *error = err(EUNSUPPORTED, [NSString stringWithFormat:@"JSON serialisation not supported for %@", [fragment class]]); 186 if (error) 187 *error = err(EUNSUPPORTED, [NSString stringWithFormat:@"JSON serialisation not supported for %@", [fragment class]]); 187 188 return NO; 188 189 } … … 200 201 else 201 202 addComma = YES; 202 203 203 204 if ([self humanReadable]) 204 205 [json appendString:[self indent]]; … … 208 209 } 209 210 } 210 211 211 212 depth--; 212 213 if ([self humanReadable] && [fragment count]) … … 219 220 [json appendString:@"{"]; 220 221 depth++; 221 222 222 223 NSString *colon = [self humanReadable] ? @" : " : @":"; 223 224 BOOL addComma = NO; … … 231 232 else 232 233 addComma = YES; 233 234 234 235 if ([self humanReadable]) 235 236 [json appendString:[self indent]]; 236 237 237 238 if (![value isKindOfClass:[NSString class]]) { 238 *error = err(EUNSUPPORTED, @"JSON object key must be string"); 239 if (error) 240 *error = err(EUNSUPPORTED, @"JSON object key must be string"); 239 241 return NO; 240 242 } … … 242 244 if (![self appendString:value into:json error:error]) 243 245 return NO; 244 246 245 247 [json appendString:colon]; 246 248 if (![self appendValue:[fragment objectForKey:value] into:json error:error]) { 247 *error = err(EUNSUPPORTED, [NSString stringWithFormat:@"Unsupported value for key %@ in object", value]); 248 return NO; 249 } 250 } 251 249 if (error) 250 *error = err(EUNSUPPORTED, [NSString stringWithFormat:@"Unsupported value for key %@ in object", value]); 251 return NO; 252 } 253 } 254 252 255 depth--; 253 256 if ([self humanReadable] && [fragment count]) … … 258 261 259 262 - (BOOL)appendString:(NSString*)fragment into:(NSMutableString*)json error:(NSError**)error { 260 263 261 264 static NSMutableCharacterSet *kEscapeChars; 262 265 if( ! kEscapeChars ) { … … 295 298 } 296 299 } 297 300 298 301 [json appendString:@"\""]; 299 302 return YES; … … 311 314 */ 312 315 - (id)objectWithString:(id)repr allowScalar:(BOOL)allowScalar error:(NSError**)error { 313 316 314 317 if (!repr) { 315 318 if (error) … … 328 331 return nil; 329 332 } 330 333 331 334 // We found some valid JSON. But did it also contain something else? 332 335 if (![self scanIsAtEnd]) { … … 335 338 return nil; 336 339 } 337 340 338 341 // If we don't allow scalars, check that the object we've found is a valid JSON container. 339 342 if (!allowScalar && ![o isKindOfClass:[NSDictionary class]] && ![o isKindOfClass:[NSArray class]]) { … … 342 345 return nil; 343 346 } 344 347 345 348 NSAssert1(o, @"Should have a valid object from %@", repr); 346 349 return o; … … 401 404 break; 402 405 case '+': 403 *error = err(EPARSENUM, @"Leading + disallowed in number"); 406 if (error) 407 *error = err(EPARSENUM, @"Leading + disallowed in number"); 404 408 return NO; 405 409 break; 406 410 case 0x0: 407 *error = err(EEOF, @"Unexpected end of string"); 411 if (error) 412 *error = err(EEOF, @"Unexpected end of string"); 408 413 return NO; 409 414 break; 410 415 default: 411 *error = err(EPARSE, @"Unrecognised leading character"); 416 if (error) 417 *error = err(EPARSE, @"Unrecognised leading character"); 412 418 return NO; 413 419 break; … … 425 431 return YES; 426 432 } 427 *error = err(EPARSE, @"Expected 'true'"); 433 if (error) 434 *error = err(EPARSE, @"Expected 'true'"); 428 435 return NO; 429 436 } … … 436 443 return YES; 437 444 } 438 *error = err(EPARSE, @"Expected 'false'"); 445 if (error) 446 *error = err(EPARSE, @"Expected 'false'"); 439 447 return NO; 440 448 } … … 447 455 return YES; 448 456 } 449 *error = err(EPARSE, @"Expected 'null'"); 457 if (error) 458 *error = err(EPARSE, @"Expected 'null'"); 450 459 return NO; 451 460 } … … 454 463 { 455 464 if (maxDepth && ++depth > maxDepth) { 456 *error = err(EDEPTH, @"Nested too deep"); 465 if (error) 466 *error = err(EDEPTH, @"Nested too deep"); 457 467 return NO; 458 468 } … … 470 480 471 481 if (![self scanValue:&v error:error]) { 472 *error = errWithUnderlier(EPARSE, error, @"Expected value while parsing array"); 482 if (error) 483 *error = errWithUnderlier(EPARSE, error, @"Expected value while parsing array"); 473 484 return NO; 474 485 } … … 480 491 skipWhitespace(c); 481 492 if (*c == ']') { 482 *error = err(ETRAILCOMMA, @"Trailing comma disallowed in array"); 493 if (error) 494 *error = err(ETRAILCOMMA, @"Trailing comma disallowed in array"); 483 495 return NO; 484 496 } … … 486 498 } 487 499 488 *error = err(EEOF, @"End of input while parsing array"); 500 if (error) 501 *error = err(EEOF, @"End of input while parsing array"); 489 502 return NO; 490 503 } … … 493 506 { 494 507 if (maxDepth && ++depth > maxDepth) { 495 *error = err(EDEPTH, @"Nested too deep"); 508 if (error) 509 *error = err(EDEPTH, @"Nested too deep"); 496 510 return NO; 497 511 } … … 509 523 510 524 if (!(*c == '\"' && c++ && [self scanRestOfString:&k error:error])) { 511 *error = errWithUnderlier(EPARSE, error, @"Object key string expected"); 525 if (error) 526 *error = errWithUnderlier(EPARSE, error, @"Object key string expected"); 512 527 return NO; 513 528 } … … 515 530 skipWhitespace(c); 516 531 if (*c != ':') { 517 *error = err(EPARSE, @"Expected ':' separating key and value"); 532 if (error) 533 *error = err(EPARSE, @"Expected ':' separating key and value"); 518 534 return NO; 519 535 } … … 522 538 if (![self scanValue:&v error:error]) { 523 539 NSString *string = [NSString stringWithFormat:@"Object value expected for key: %@", k]; 524 *error = errWithUnderlier(EPARSE, error, string); 540 if (error) 541 *error = errWithUnderlier(EPARSE, error, string); 525 542 return NO; 526 543 } … … 532 549 skipWhitespace(c); 533 550 if (*c == '}') { 534 *error = err(ETRAILCOMMA, @"Trailing comma disallowed in object"); 551 if (error) 552 *error = err(ETRAILCOMMA, @"Trailing comma disallowed in object"); 535 553 return NO; 536 554 } … … 538 556 } 539 557 540 *error = err(EEOF, @"End of input while parsing object"); 558 if (error) 559 *error = err(EEOF, @"End of input while parsing object"); 541 560 return NO; 542 561 } … … 583 602 c++; 584 603 if (![self scanUnicodeChar:&uc error:error]) { 585 *error = errWithUnderlier(EUNICODE, error, @"Broken unicode character"); 604 if (error) 605 *error = errWithUnderlier(EUNICODE, error, @"Broken unicode character"); 586 606 return NO; 587 607 } … … 589 609 break; 590 610 default: 591 *error = err(EESCAPE, [NSString stringWithFormat:@"Illegal escape sequence '0x%x'", uc]); 611 if (error) 612 *error = err(EESCAPE, [NSString stringWithFormat:@"Illegal escape sequence '0x%x'", uc]); 592 613 return NO; 593 614 break; … … 597 618 598 619 } else if (*c < 0x20) { 599 *error = err(ECTRL, [NSString stringWithFormat:@"Unescaped control character '0x%x'", *c]); 620 if (error) 621 *error = err(ECTRL, [NSString stringWithFormat:@"Unescaped control character '0x%x'", *c]); 600 622 return NO; 601 623 … … 605 627 } while (*c); 606 628 607 *error = err(EEOF, @"Unexpected EOF while parsing string"); 629 if (error) 630 *error = err(EEOF, @"Unexpected EOF while parsing string"); 608 631 return NO; 609 632 } … … 614 637 615 638 if (![self scanHexQuad:&hi error:error]) { 616 *error = err(EUNICODE, @"Missing hex quad"); 639 if (error) 640 *error = err(EUNICODE, @"Missing hex quad"); 617 641 return NO; 618 642 } … … 622 646 623 647 if (!(*c == '\\' && ++c && *c == 'u' && ++c && [self scanHexQuad:&lo error:error])) { 624 *error = errWithUnderlier(EUNICODE, error, @"Missing low character in surrogate pair"); 648 if (error) 649 *error = errWithUnderlier(EUNICODE, error, @"Missing low character in surrogate pair"); 625 650 return NO; 626 651 } 627 652 628 653 if (lo < 0xdc00 || lo >= 0xdfff) { 629 *error = err(EUNICODE, @"Invalid low surrogate char"); 654 if (error) 655 *error = err(EUNICODE, @"Invalid low surrogate char"); 630 656 return NO; 631 657 } … … 634 660 635 661 } else if (hi < 0xe000) { 636 *error = err(EUNICODE, @"Invalid high character in surrogate pair"); 662 if (error) 663 *error = err(EUNICODE, @"Invalid high character in surrogate pair"); 637 664 return NO; 638 665 } … … 654 681 ? (uc - 'A' + 10) : -1; 655 682 if (d == -1) { 656 *error = err(EUNICODE, @"Missing hex digit in quad"); 683 if (error) 684 *error = err(EUNICODE, @"Missing hex digit in quad"); 657 685 return NO; 658 686 } … … 676 704 if ('0' == *c && c++) { 677 705 if (isdigit(*c)) { 678 *error = err(EPARSENUM, @"Leading 0 disallowed in number"); 706 if (error) 707 *error = err(EPARSENUM, @"Leading 0 disallowed in number"); 679 708 return NO; 680 709 } 681 710 682 711 } else if (!isdigit(*c) && c != ns) { 683 *error = err(EPARSENUM, @"No digits after initial minus"); 712 if (error) 713 *error = err(EPARSENUM, @"No digits after initial minus"); 684 714 return NO; 685 715 … … 692 722 693 723 if (!isdigit(*c)) { 694 *error = err(EPARSENUM, @"No digits after decimal point"); 724 if (error) 725 *error = err(EPARSENUM, @"No digits after decimal point"); 695 726 return NO; 696 727 } … … 706 737 707 738 if (!isdigit(*c)) { 708 *error = err(EPARSENUM, @"No digits after exponent"); 739 if (error) 740 *error = err(EPARSENUM, @"No digits after exponent"); 709 741 return NO; 710 742 } … … 720 752 return YES; 721 753 722 *error = err(EPARSENUM, @"Failed creating decimal instance"); 754 if (error) 755 *error = err(EPARSENUM, @"Failed creating decimal instance"); 723 756 return NO; 724 757 } -
apps/iphone/my.tel/trunk/VIP.tel.xcodeproj/project.pbxproj
r656 r673 1005 1005 GCC_PREPROCESSOR_DEFINITIONS = DEBUG; 1006 1006 GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; 1007 GCC_WARN_ABOUT_MISSING_NEWLINE = YES;1008 1007 GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 1009 1008 GCC_WARN_ABOUT_RETURN_TYPE = YES; … … 1016 1015 GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; 1017 1016 GCC_WARN_SHADOW = YES; 1018 GCC_WARN_SIGN_COMPARE = YES;1019 1017 GCC_WARN_UNDECLARED_SELECTOR = YES; 1020 1018 GCC_WARN_UNINITIALIZED_AUTOS = YES; -
apps/iphone/superbook/trunk/DotTel_SDK/Classes/Reachability.h
r357 r673 96 96 - (NetworkStatus)localWiFiConnectionStatus; 97 97 98 /*99 When reachability change notifications are posted, the callback method 'ReachabilityCallback' is called100 and posts a notification that the client application can observe to learn about changes.101 */102 static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info);103 98 104 99 @end -
apps/iphone/superbook/trunk/DotTel_SDK/Classes/Reachability.m
r357 r673 70 70 - (BOOL)addressFromString:(NSString *)IPAddress address:(struct sockaddr_in *)outAddress; 71 71 - (void)stopListeningForReachabilityChanges; 72 /* 73 When reachability change notifications are posted, the callback method 'ReachabilityCallback' is called 74 and posts a notification that the client application can observe to learn about changes. 75 */ 76 static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info); 72 77 @end 73 78 … … 154 159 155 160 // Build a sockaddr_in that we can pass to the address reachability query. 156 struct sockaddr_in s in;157 158 bzero(&s in, sizeof(sin));159 s in.sin_len = sizeof(sin);160 s in.sin_family = AF_INET;161 struct sockaddr_in soin; 162 163 bzero(&soin, sizeof(soin)); 164 soin.sin_len = sizeof(soin); 165 soin.sin_family = AF_INET; 161 166 // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0 162 s in.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);163 164 adHocWiFiNetworkReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&s in);167 soin.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM); 168 169 adHocWiFiNetworkReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&soin); 165 170 166 171 query = [[[ReachabilityQuery alloc] init] autorelease]; … … 225 230 defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&zeroAddress); 226 231 227 ReachabilityQuery *query = [[[ReachabilityQuery alloc] init] autorelease];228 query .hostNameOrAddress = kDefaultRouteKey;229 query .reachabilityRef = defaultRouteReachability;230 231 [self.reachabilityQueries setObject:query forKey:kDefaultRouteKey];232 ReachabilityQuery *query2 = [[[ReachabilityQuery alloc] init] autorelease]; 233 query2.hostNameOrAddress = kDefaultRouteKey; 234 query2.reachabilityRef = defaultRouteReachability; 235 236 [self.reachabilityQueries setObject:query2 forKey:kDefaultRouteKey]; 232 237 } 233 238








