Changeset 768 for apps/iphone
- Timestamp:
- 01/11/11 13:30:12 (2 years ago)
- Location:
- apps/iphone/my.tel/trunk/Classes
- Files:
-
- 3 modified
-
KeywordViewController.m (modified) (3 diffs)
-
RecordViewController.h (modified) (1 diff)
-
RecordViewController.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apps/iphone/my.tel/trunk/Classes/KeywordViewController.m
r651 r768 39 39 theC.uiArray = [NSMutableArray arrayWithCapacity:20]; 40 40 if (preload) { 41 [theC getValidKeywords: FALSE];41 [theC getValidKeywords:TRUE]; 42 42 [theC getKeywords]; 43 43 } … … 61 61 didPreload = NO; 62 62 } else { 63 [self getValidKeywords: FALSE];63 [self getValidKeywords:TRUE]; 64 64 [self getKeywords]; 65 65 } … … 301 301 if (!parsedJson) { 302 302 // We're loading the data statically (not from the network) 303 // Note: you must localize the resource if loading the data statically 303 304 keywordTypesNames = [[NSMutableDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] 304 305 pathForResource:@"KeywordTypesLongNames" -
apps/iphone/my.tel/trunk/Classes/RecordViewController.h
r613 r768 46 46 - (void)deleteRecords:(NSDictionary *)aRec; 47 47 - (void)orderRecords; 48 - (void)getServiceKeys:(BOOL)fromNetwork; 49 - (void)getLocations:(BOOL)fromNetwork; 48 50 49 51 @property (nonatomic, retain) NSMutableDictionary *skeysDict; -
apps/iphone/my.tel/trunk/Classes/RecordViewController.m
r678 r768 35 35 RecordViewController *theC = [[[RecordViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease]; 36 36 theC.delegate = aDelegate; 37 theC.skeysDict = [NSMutableDictionary dictionaryWithContentsOfFile: 38 [[NSBundle mainBundle] pathForResource:@"ServiceTypes" ofType:@"plist"]]; 39 theC.liDict = [NSMutableDictionary dictionaryWithContentsOfFile: 40 [[NSBundle mainBundle] pathForResource:@"LocationIndicators" ofType:@"plist"]]; 37 [theC getServiceKeys:TRUE]; 38 [theC getLocations:TRUE]; 41 39 theC.recordsArray = [NSMutableArray arrayWithCapacity:20]; 42 40 theC.uiArray = [NSMutableArray arrayWithCapacity:20]; … … 431 429 [liPart appendString:@" & "]; 432 430 NSString *anLI = (NSString *)[[jsonItem objectForKey:@"locations"] objectAtIndex:i]; 433 [liPart appendString:[self.liDict objectForKey:anLI]]; 431 if ([self.liDict objectForKey:anLI] != nil) { 432 [liPart appendString:[self.liDict objectForKey:anLI]]; 433 } else { 434 [liPart appendString:anLI]; 435 } 434 436 if ([anLI isEqualToString:@"x-mobile"] && couldbeMobilePhone) { 435 437 [uiItem setObject:[[RecordViewController imageMappings] objectForKey:@"mobile"] forKey:@"imageName"]; … … 597 599 } 598 600 601 - (void)getServiceKeys:(BOOL)fromNetwork { 602 // successResult = { 603 // success: true, 604 // serviceKeys: [{key: "voice", label: "Voice Call", id: -1}, 605 // {key: "fax", label: "Fax", id: -1}, 606 // {key: "x-c2c", label: "Click2Communicate", id: 21}], 607 // actionMessages: "request successful", 608 // "2nd message here", 609 // "3rd message here"] 610 // }; 611 612 if (fromNetwork) { 613 Record *conn = [[[Record alloc] init] autorelease]; 614 [conn setTheDelegate:[MyTelConnect sharedInstance]]; 615 [conn setActionSel:@selector(doNothing:)]; 616 [conn setConnectionUrl:[conn urlFromAction:@"getservicekeys"]]; 617 618 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 619 // [requestData setObject:[self.delegate domain] forKey:@"domain"]; 620 621 [conn setPayload:requestData]; 622 NSDictionary *parsedJson = [conn performLookup:FALSE]; 623 [requestData release]; 624 self.skeysDict = [NSMutableDictionary dictionaryWithCapacity:20]; 625 if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 626 NSArray *serviceKeys = (NSArray *)[parsedJson valueForKey:@"serviceKeys"]; 627 NSDictionary *aKey; 628 for (aKey in serviceKeys) { 629 [skeysDict setObject:(NSString *)[aKey objectForKey:@"label"] 630 forKey:(NSString *)[aKey objectForKey:@"key"]]; 631 } 632 } else { 633 [Record throwJsonErrorAlert:parsedJson]; 634 } 635 } else { 636 self.skeysDict = [NSMutableDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] 637 pathForResource:@"ServiceTypes" 638 ofType:@"plist"]]; 639 } 640 } 641 642 - (void)getLocations:(BOOL)fromNetwork { 643 // successResult = { 644 // success: true, 645 // locations: ["x-home", "Home", "x-work", "Work", "x-main", 646 // "Main Contact"], 647 // actionMessages: "request successful", 648 // "2nd message here", 649 // "3rd message here"] 650 // }; 651 652 if (fromNetwork) { 653 Record *conn = [[[Record alloc] init] autorelease]; 654 [conn setTheDelegate:[MyTelConnect sharedInstance]]; 655 [conn setActionSel:@selector(doNothing:)]; 656 [conn setConnectionUrl:[conn urlFromAction:@"getlocations"]]; 657 658 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 659 // [requestData setObject:[self.delegate domain] forKey:@"domain"]; 660 661 [conn setPayload:requestData]; 662 NSDictionary *parsedJson = [conn performLookup:FALSE]; 663 [requestData release]; 664 self.liDict = [NSMutableDictionary dictionaryWithCapacity:10]; 665 if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 666 NSArray *liArray = (NSArray *)[parsedJson valueForKey:@"locations"]; 667 NSUInteger i, count = [liArray count]; 668 for (i = 0; i < count; i = i + 2) { 669 [liDict setObject:(NSString *)[liArray objectAtIndex:(i+1)] 670 forKey:(NSString *)[liArray objectAtIndex:i]]; 671 } 672 } else { 673 [Record throwJsonErrorAlert:parsedJson]; 674 } 675 } else { 676 self.liDict = [NSMutableDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] 677 pathForResource:@"LocationIndicators" 678 ofType:@"plist"]]; 679 } 680 } 681 599 682 #pragma mark - 600 683 #pragma mark TelControllerDelegate methods








