Developer Area

Changeset 213 for apps/iphone/my.tel

Show
Ignore:
Timestamp:
01/29/09 16:18:27 (6 years ago)
Author:
henri
Message:

Allowed for cached keyword types

Location:
apps/iphone/my.tel/trunk/Classes
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • apps/iphone/my.tel/trunk/Classes/KeywordViewController.h

    r205 r213  
    3737- (void)storeKeyword:(NSDictionary *)aRec;      // Could be a set of primary+secondaries 
    3838- (void)deleteKeywords:(NSDictionary *)aRec; 
    39 - (void)getValidKeywords; 
     39- (void)getValidKeywords:(BOOL)fromNetwork; 
    4040 
    4141@property (nonatomic, retain) NSMutableDictionary *validKeywordTypes; 
  • apps/iphone/my.tel/trunk/Classes/KeywordViewController.m

    r205 r213  
    3737        rowsToDelete = [[NSMutableDictionary dictionaryWithCapacity:5] retain]; 
    3838        keywordTableHeight = kKRowHeight; 
    39         [self getValidKeywords]; 
     39        [self getValidKeywords:FALSE]; 
    4040} 
    4141 
     
    273273 
    274274- (void)fillValidKeywordsDict:(NSDictionary *)parsedJson { 
    275         if (!parsedJson) 
    276                 return; 
    277275        if (!self.validKeywordTypes) { 
    278276                self.validKeywordTypes = [[NSMutableDictionary dictionaryWithCapacity:20] retain]; 
     
    280278                [self.validKeywordTypes removeAllObjects]; 
    281279        } 
    282         // TODO: Why do we check success here, and not in the record's fillServicesDict and fillLocationsDict? 
    283         if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 
    284                 NSArray *keyTypeList = (NSArray *)[parsedJson valueForKey:@"validKeywordList"]; 
    285                 NSDictionary *aKeyType; 
    286                 for (aKeyType in keyTypeList) { 
    287                         [self.validKeywordTypes setObject:(NSString *)[aKeyType objectForKey:@"displayText"] 
    288                          forKey:(NSString *)[aKeyType objectForKey:@"shortForm"]]; 
     280        if (!parsedJson) { 
     281                // We're loading the data statically (not from the network) 
     282                self.validKeywordTypes = [NSMutableDictionary dictionaryWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] 
     283                                                                                                                                                           stringByAppendingPathComponent:@"KeywordTypes.plist"]]; 
     284        } else { 
     285                if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 
     286                        NSArray *keyTypeList = (NSArray *)[parsedJson valueForKey:@"validKeywordList"]; 
     287                        NSDictionary *aKeyType; 
     288                        for (aKeyType in keyTypeList) { 
     289                                [self.validKeywordTypes setObject:(NSString *)[aKeyType objectForKey:@"displayText"] 
     290                                 forKey:(NSString *)[aKeyType objectForKey:@"shortForm"]]; 
     291                        } 
     292                } else { 
     293                        [Keyword throwJsonErrorAlert:parsedJson]; 
    289294                } 
    290         } else { 
    291                 [Keyword throwJsonErrorAlert:parsedJson]; 
    292295        } 
    293296} 
     
    452455} 
    453456 
    454 - (void)getValidKeywords { 
     457- (void)getValidKeywords:(BOOL)fromNetwork { 
    455458        //      successResult = { 
    456459        //      success: true, 
     
    465468        //      }; 
    466469         
    467         Keyword *conn = [[[Keyword alloc] init] autorelease]; 
    468         [conn setTheDelegate:[VIPConnect sharedInstance]]; 
    469         [conn setActionSel:@selector(doNothing:)]; 
    470         [conn setConnectionUrl:[conn urlFromAction:@"getvalidkeywords"]]; 
    471          
    472         NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 
    473         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 
    474          
    475         [conn setPayload:requestData]; 
    476         NSDictionary *parsedJson = [conn performLookup:FALSE]; 
    477         [self fillValidKeywordsDict:parsedJson]; 
    478         [requestData release]; 
     470        if (fromNetwork) { 
     471                Keyword *conn = [[[Keyword alloc] init] autorelease]; 
     472                [conn setTheDelegate:[VIPConnect sharedInstance]]; 
     473                [conn setActionSel:@selector(doNothing:)]; 
     474                [conn setConnectionUrl:[conn urlFromAction:@"getvalidkeywords"]]; 
     475                 
     476                NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 
     477                [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 
     478                 
     479                [conn setPayload:requestData]; 
     480                NSDictionary *parsedJson = [conn performLookup:FALSE]; 
     481                [self fillValidKeywordsDict:parsedJson]; 
     482                [requestData release]; 
     483        } else { 
     484                [self fillValidKeywordsDict:nil]; 
     485        } 
    479486} 
    480487 
Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us