Developer Area

Changeset 589

Show
Ignore:
Timestamp:
12/03/09 11:13:52 (3 months ago)
Author:
henri
Message:

First commit on what will become the 2.0 version.

Location:
apps/iphone/my.tel/trunk
Files:
29 added
20 removed
33 modified

Legend:

Unmodified
Added
Removed
  • apps/iphone/my.tel/trunk/APISubdomain.plist

    r218 r589  
    77        <key>storefolder</key> 
    88        <string>/domain/storefolder.action</string> 
     9        <key>renamefolder</key> 
     10        <string>/domain/renamefolder.action</string> 
    911        <key>deletefolder</key> 
    1012        <string>/domain/deletefolder.action</string> 
     13        <key>getdisplaystring</key> 
     14        <string>/domain/getdisplaystring.action</string> 
     15        <key>setdisplaystring</key> 
     16        <string>/domain/setdisplaystring.action</string> 
    1117</dict> 
    1218</plist> 
  • apps/iphone/my.tel/trunk/Classes/AlertRenameView.m

    r266 r589  
    1212// and the width of the text field inside 
    1313#define kARTextFieldDiff 50 
     14// Height of text field 
     15#define kARTextFieldHeight 32 
    1416 
    1517@implementation AlertRenameView 
     
    4547        [super drawRect:rect]; 
    4648        CGRect boundsRect = self.bounds; 
    47         // Move the alert view upwards so the keyboard can be shown properly 
    48         self.frame = CGRectOffset(self.frame, 0, -80); 
    4949    CGRect textRect = boundsRect; 
    50         textRect.size = CGSizeMake(rect.size.width - kARTextFieldDiff, 32); 
    51         textRect = CGRectOffset(textRect, kARTextFieldDiff/2 , 50); 
     50        textRect.size = CGSizeMake(rect.size.width - kARTextFieldDiff, kARTextFieldHeight); 
     51        textRect = CGRectOffset(textRect, kARTextFieldDiff/2 , kARTextFieldHeight+18); 
    5252        uiStringField.frame = textRect; 
    5353} 
     
    6565        return YES; 
    6666} 
    67 - (BOOL)textFieldShouldEndEditing:(UITextField *)textField { 
    68         if ([textField.text isEqual:@""]) { 
    69                 return NO; 
    70         } 
     67- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { 
     68        self.frame = CGRectOffset(self.frame, 0, -(48+kARTextFieldHeight)); 
    7169        return YES; 
    7270} 
    7371- (void)textFieldDidEndEditing:(UITextField *)textField { 
     72        self.frame = CGRectOffset(self.frame, 0, 48+kARTextFieldHeight); 
    7473} 
    7574@end 
  • apps/iphone/my.tel/trunk/Classes/GroupFriendsController.h

    r313 r589  
    1212#import "Group.h" 
    1313 
    14 @protocol GroupDetailsDelegate <NSObject> 
    15 @required 
    16 - (void)didModifyGroup:(NSDictionary *)aGroup; 
    17 @end 
    18  
    1914@interface GroupFriendsController : UIViewController 
    2015<UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate, UIActionSheetDelegate> { 
     
    2217        IBOutlet UIBarButtonItem *buttonEdit; 
    2318        NSDictionary *theGroup;                 // Group for which friends are requested 
    24         id delegate; 
     19        id <TelControllerDelegate>delegate; 
    2520@private 
    2621        NSMutableArray *friendsArray;   // retrieved raw JSON data of getgroupfriends 
     
    5752@property (nonatomic, retain) UIBarButtonItem *buttonEdit; 
    5853@property (nonatomic, retain) NSDictionary *theGroup; 
    59 @property (nonatomic,assign) id <GroupDetailsDelegate> delegate; 
     54@property (nonatomic,assign) id <TelControllerDelegate> delegate; 
    6055@end 
  • apps/iphone/my.tel/trunk/Classes/GroupFriendsController.m

    r535 r589  
    6161         
    6262        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 
    63         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     63        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    6464        [requestData setObject:[theGroup objectForKey:@"id"] forKey:@"groupId"]; 
    6565         
     
    6868        [requestData release]; 
    6969        if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 
    70                 [self.delegate didModifyGroup:theGroup]; 
     70                [self.delegate dataDidLoadForController:self]; 
    7171                [self.navigationController popViewControllerAnimated:YES]; 
    7272        } else { 
     
    8888         
    8989        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; 
    90         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     90        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    9191        [requestData setObject:[theGroup objectForKey:@"id"] forKey:@"groupId"]; 
    9292        [requestData setObject:newName forKey:@"groupName"]; 
     
    201201                [theGroup setValue:newGroupName forKey:@"groupName"]; 
    202202                self.navigationItem.title = newGroupName; 
    203                 [self.delegate didModifyGroup:theGroup]; 
     203                // Tell the delegate something changed 
     204                //[self.delegate didModifyGroup:theGroup]; 
     205                [self.delegate dataDidLoadForController:self]; 
    204206        } else { 
    205207                [Group throwJsonErrorAlert:parsedJson]; 
     
    231233         
    232234        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:50] retain]; 
    233         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     235        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    234236        [requestData setObject:[theGroup objectForKey:@"id"] forKey:@"groupId"]; 
    235237 
     
    247249         
    248250        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:50] retain]; 
    249         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     251        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    250252        // allFriendsGroupId should already be set. 
    251253        [requestData setObject:[VIPConnect sharedInstance].allFriendsGroupId forKey:@"groupId"]; 
     
    301303         
    302304        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:50] retain]; 
    303         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     305        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    304306        [requestData setObject:[theGroup objectForKey:@"id"] forKey:@"groupId"]; 
    305307        [requestData setObject:friendsIdList forKey:@"readerIds"]; 
     
    332334         
    333335        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:50] retain]; 
    334         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     336        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    335337        [requestData setObject:[theGroup objectForKey:@"id"] forKey:@"groupId"]; 
    336338        [requestData setObject:friendsIdList forKey:@"readerIds"]; 
  • apps/iphone/my.tel/trunk/Classes/GroupsViewController.h

    r249 r589  
    1313 
    1414 
    15 @interface GroupsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, 
    16                                                                                                         UIAlertViewDelegate, GroupDetailsDelegate> { 
     15@interface GroupsViewController : UITableViewController 
     16<UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate, TelControllerDelegate> { 
    1717        NSMutableArray *groupsArray;    // retrieved raw JSON data (also used as the datasource array) 
    18  
    19         IBOutlet UITableView *theTable; 
    20         IBOutlet UIBarButtonItem *buttonAdd; 
     18        id <TelControllerDelegate> delegate; 
     19@private 
     20        BOOL didPreload; 
    2121} 
    2222 
     23+ (GroupsViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload; 
    2324- (void)updateUITableWithJson:(NSDictionary *)parsedJson; 
    2425 
     
    2627- (void)createGroup:(NSString *)aGroupName; 
    2728 
    28 @property (nonatomic, retain) NSMutableArray *groupsArray; 
    2929 
    3030- (IBAction)didClickAdd:(id)sender; 
    3131 
    32 @property (nonatomic, retain) UITableView *theTable; 
    33 @property (nonatomic, retain) UIBarButtonItem *buttonAdd; 
     32@property (nonatomic, retain) NSMutableArray *groupsArray; 
     33@property (retain) id delegate; 
    3434 
    3535@end 
  • apps/iphone/my.tel/trunk/Classes/GroupsViewController.m

    r535 r589  
    99#import "GroupsViewController.h" 
    1010 
     11@interface GroupsViewController (PrivateMethods) 
     12- (void)setDidPreload:(BOOL)preload; 
     13@end; 
     14 
    1115 
    1216@implementation GroupsViewController 
    1317 
    1418@synthesize groupsArray; 
    15 @synthesize theTable; 
    16 @synthesize buttonAdd; 
     19@synthesize delegate; 
    1720 
    1821#define kAlertAddId 1 
    1922 
     23#pragma mark - 
     24#pragma mark Designated initializer 
     25 
     26+ (GroupsViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload { 
     27        GroupsViewController *theC = [[[GroupsViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease]; 
     28        theC.delegate = aDelegate; 
     29        theC.groupsArray = [NSMutableArray arrayWithCapacity:10]; 
     30        if (preload) { 
     31                [theC listGroups]; 
     32        } 
     33        [theC setDidPreload:preload]; 
     34        return theC;     
     35} 
     36 
     37- (void)setDidPreload:(BOOL)preload { 
     38        didPreload = preload; 
     39} 
     40 
     41 
    2042#pragma mark ------ Default Methods 
    21 /* 
    22 // The designated initializer. Override to perform setup that is required before the view is loaded. 
    23 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
    24     if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { 
    25         // Custom initialization 
    26     } 
    27     return self; 
    28 } 
    29 */ 
    30  
    31 /* 
    32 // Implement loadView to create a view hierarchy programmatically, without using a nib. 
    33 - (void)loadView { 
    34 } 
    35 */ 
    36  
    3743- (void)viewDidLoad { 
    3844    [super viewDidLoad]; 
    39         [[VIPConnect sharedInstance] addObserver:self forKeyPath:@"selectedDomain" options:NSKeyValueObservingOptionNew context:NULL]; 
    40         self.groupsArray = [NSMutableArray arrayWithCapacity:10]; 
    41         self.navigationItem.rightBarButtonItem = buttonAdd; 
    42         [self listGroups]; 
    43 } 
    44  
    45 /* 
    46 // Override to allow orientations other than the default portrait orientation. 
     45        self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
     46                                                                                                                                                                                        target:self 
     47                                                                                                                                                                                        action:@selector(didClickAdd:)] 
     48                                                                                          autorelease]; 
     49        self.title = @"Privacy Groups"; 
     50} 
     51 
     52 
     53- (void)viewWillAppear:(BOOL)animated { 
     54        [super viewWillAppear:animated]; 
     55        // Don't get the data if we preloaded 
     56        if (didPreload) { 
     57                didPreload = NO; 
     58        } else { 
     59                [self listGroups]; 
     60        } 
     61} 
     62 
    4763- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    4864    // Return YES for supported orientations 
    4965    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
    5066} 
    51 */ 
    5267 
    5368- (void)didReceiveMemoryWarning { 
     
    153168                        // no groups 
    154169                } 
    155         } else { 
     170                [self.delegate dataDidLoadForController:self]; 
     171                [self.tableView reloadData]; 
     172        } else { 
     173                [self.tableView reloadData]; 
    156174                [Group throwJsonErrorAlert:parsedJson]; 
    157175        } 
    158         [theTable reloadData]; 
    159 } 
    160  
    161 #pragma mark ------ GroupDetailsDelegate methods 
    162  
    163 - (void)didModifyGroup:(NSDictionary *)aGroup { 
    164         [self listGroups]; 
     176} 
     177 
     178#pragma mark ------ TelControllerDelegate methods 
     179 
     180- (void)dataDidLoadForController:(UIViewController *)controller { 
     181        if ([controller isMemberOfClass:[GroupFriendsController class]]) { 
     182                [self listGroups]; 
     183        } 
     184} 
     185 
     186- (NSString *)domain { 
     187        // request the domain from the calling controller 
     188        return [self.delegate domain]; 
    165189} 
    166190 
     
    205229         
    206230        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 
    207         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     231        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    208232         
    209233        [conn setPayload:requestData]; 
     
    235259        // create empty group 
    236260        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; 
    237         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     261        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    238262        [requestData setObject:@"0" forKey:@"groupId"]; 
    239263        [requestData setObject:aGroupName forKey:@"groupName"]; 
     
    251275                                                                nil]; 
    252276                [groupsArray addObject:newGroup]; 
    253                 NSIndexPath *lastPath = [NSIndexPath indexPathForRow:[theTable numberOfRowsInSection:0] inSection:0]; 
    254                 [theTable insertRowsAtIndexPaths:[NSArray arrayWithObject:lastPath] withRowAnimation:UITableViewRowAnimationFade]; 
     277                NSIndexPath *lastPath = [NSIndexPath indexPathForRow:[self.tableView numberOfRowsInSection:0] inSection:0]; 
     278                [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:lastPath] withRowAnimation:UITableViewRowAnimationFade]; 
    255279        } 
    256280        [aGroupName release]; 
     
    265289                       context:(void *)context { 
    266290         
    267         if ([keyPath isEqual:@"selectedProfileName"]) { 
     291        if ([keyPath isEqual:@"selectedDomain"]) { 
    268292                [self listGroups];               
    269293                return; 
  • apps/iphone/my.tel/trunk/Classes/KeywordCell.m

    r264 r589  
    1717@synthesize labelSecondaryText; 
    1818 
    19 - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier { 
    20     if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) { 
     19- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 
     20    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 
    2121        // Initialization code 
    2222                 
  • apps/iphone/my.tel/trunk/Classes/KeywordEditController.h

    r161 r589  
    1919#import "biKeywordView.h" 
    2020 
    21 @protocol KeywordEditDelegate 
     21@protocol KeywordEditDelegate <TelControllerDelegate> 
    2222 
    2323- (void)didStoreKeyword:(NSDictionary *)aRec; 
     
    3939        IBOutlet UIView *editSubview;   // Subview with editing fields 
    4040         
    41         id <KeywordEditDelegate> caller; 
     41        id <KeywordEditDelegate> delegate; 
    4242@private 
    4343        NSMutableArray *tArrKey; 
     
    6666@property (nonatomic, retain) IBOutlet UIView *editSubview; 
    6767@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *saveIndicator; 
    68 @property (retain) id caller; 
     68@property (retain) id delegate; 
    6969 
    7070@end 
  • apps/iphone/my.tel/trunk/Classes/KeywordEditController.m

    r535 r589  
    3030@synthesize editSubview; 
    3131@synthesize saveIndicator; 
    32 @synthesize caller; 
     32@synthesize delegate; 
    3333 
    3434#pragma mark ------ Transition methods 
     
    5050                rValue.textColor = [UIColor blackColor]; 
    5151                [theKeyword setObject:@"0" forKey:@"primaryKeywordId"]; 
    52                 [theKeyword setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 
     52                [theKeyword setObject:[self.delegate domain] forKey:@"domain"]; 
    5353                primaryKeywords.hidden = NO; 
    5454                [self displaySecondaryViewAtIndex:primaryKeywords.selectedSegmentIndex]; 
     
    6262                theKeyword = [[NSMutableDictionary dictionaryWithCapacity:[aRec count]] retain]; 
    6363                [theKeyword setDictionary:aRec]; 
    64                 editKeywordType.text = [[caller delegateKeywordTypes] objectForKey:[theKeyword objectForKey:@"field"]]; 
     64                editKeywordType.text = [[delegate delegateKeywordTypes] objectForKey:[theKeyword objectForKey:@"field"]]; 
    6565                barHeader.title = @"View Keyword"; 
    6666                barButtonSave.enabled = FALSE; 
    67                 [theKeyword setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 
     67                [theKeyword setObject:[self.delegate domain] forKey:@"domain"]; 
    6868                rValue.text = [theKeyword objectForKey:@"value"]; 
    6969                rValue.textColor = [UIColor whiteColor]; 
     
    7171                NSMutableString *secDesc = [NSMutableString stringWithCapacity:100]; 
    7272                for (NSDictionary *sec in [theKeyword objectForKey:@"secondaryKeywords"]) { 
    73                         [secDesc appendFormat:@"%@: %@\n", [[caller delegateKeywordTypes] objectForKey:[sec objectForKey:@"field"]], 
     73                        [secDesc appendFormat:@"%@: %@\n", [[delegate delegateKeywordTypes] objectForKey:[sec objectForKey:@"field"]], 
    7474                         [sec objectForKey:@"value"]]; 
    7575                } 
     
    7878                 
    7979                // TODO: Enable keyword editing 
    80                 //NSDictionary *validKeywordTypes = [[caller delegateKeywordTypes] retain]; 
     80                //NSDictionary *validKeywordTypes = [[delegate delegateKeywordTypes] retain]; 
    8181        } 
    8282         
    8383        [self viewWillAppear:YES]; 
    8484        // Insert our view just at the top of the caller's subview stack 
    85         [[(UIViewController *)caller view] addSubview:self.view]; 
     85        [[(UIViewController *)delegate view] addSubview:self.view]; 
    8686        // Set up the animation 
    8787    CATransition *animation = [CATransition animation]; 
     
    9595    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 
    9696     
    97     [[[(UIViewController *)caller view] layer] addAnimation:animation forKey:@"kEditAnimation"]; 
     97    [[[(UIViewController *)delegate view] layer] addAnimation:animation forKey:@"kEditAnimation"]; 
    9898         
    9999} 
     
    164164        // store all the keyword info 
    165165        NSMutableDictionary *saveKeywordDict = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 
    166         [saveKeywordDict setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 
     166        [saveKeywordDict setObject:[self.delegate domain] forKey:@"domain"]; 
    167167        NSMutableArray *saveSecKeywordArray = [[NSMutableArray arrayWithCapacity:8] retain]; 
    168168        [saveSecKeywordArray addObject:[NSDictionary dictionaryWithObjectsAndKeys: 
     
    197197- (void)afterSaveAction:(NSDictionary *)parsedJson { 
    198198        if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 
    199                 [caller didStoreKeyword:theKeyword]; 
     199                [delegate didStoreKeyword:theKeyword]; 
    200200                [self.view removeFromSuperview]; 
    201201        } else { 
  • apps/iphone/my.tel/trunk/Classes/KeywordViewController.h

    r426 r589  
    2727        IBOutlet UINavigationBar *navBar; 
    2828        IBOutlet KeywordEditController *editController; 
     29        id <TelControllerDelegate> delegate; 
    2930@private 
     31        BOOL didPreload; 
    3032} 
    3133 
     34+ (KeywordViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload; 
    3235- (NSDictionary *)selectRecordInSetUsingId:(NSString *)anId; 
    3336- (void)updateUITableWithJson:(NSDictionary *)parsedJson; 
     
    5457@property (nonatomic, retain) IBOutlet UINavigationBar *navBar; 
    5558@property (nonatomic, retain) IBOutlet KeywordEditController *editController; 
     59@property (retain) id delegate; 
    5660 
    5761@end 
  • apps/iphone/my.tel/trunk/Classes/KeywordViewController.m

    r535 r589  
    1616#define kKRowLineHeightIncrease 20.0 
    1717 
     18@interface KeywordViewController (PrivateMethods) 
     19- (void)setDidPreload:(BOOL)preload; 
     20@end; 
     21 
    1822@implementation KeywordViewController 
    1923 
     
    2933@synthesize navBar; 
    3034@synthesize editController; 
     35@synthesize delegate; 
     36 
     37#pragma mark - 
     38#pragma mark Designated initializer 
     39 
     40+ (KeywordViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload { 
     41        KeywordViewController *theC = [[[KeywordViewController alloc] initWithNibName:@"TabTxt" bundle:nil] autorelease]; 
     42        theC.delegate = aDelegate; 
     43        theC.keywordsArray = [NSMutableArray arrayWithCapacity:20]; 
     44        theC.uiArray = [NSMutableArray arrayWithCapacity:20]; 
     45        if (preload) { 
     46                [theC getValidKeywords:FALSE]; 
     47                [theC getKeywords]; 
     48        } 
     49        [theC setDidPreload:preload]; 
     50        return theC;     
     51} 
     52 
     53- (void)setDidPreload:(BOOL)preload { 
     54        didPreload = preload; 
     55} 
    3156 
    3257#pragma mark ------ Standard View Controller Methods 
     
    3459- (void)viewDidLoad { 
    3560    [super viewDidLoad]; 
    36         self.keywordsArray = [NSMutableArray arrayWithCapacity:20]; 
    37         self.uiArray = [NSMutableArray arrayWithCapacity:20]; 
    3861        keywordTableHeight = kKRowHeight; 
    39         [self getValidKeywords:FALSE]; 
    4062} 
    4163 
    4264- (void)viewWillAppear:(BOOL)animated { 
    43         // This triggers when switching tabs 
    44         self.title = navBar.topItem.title = [VIPConnect sharedInstance].selectedDomain; 
    45         [self getKeywords]; 
     65        [super viewWillAppear:animated]; 
     66        // Don't get the data if we preloaded 
     67        if (didPreload) { 
     68                didPreload = NO; 
     69        } else { 
     70                [self getValidKeywords:FALSE]; 
     71                [self getKeywords]; 
     72        } 
    4673} 
    4774 
     
    5986- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 
    6087        return nil; 
    61         //return [NSString stringWithFormat:@"Profile: %@", [VIPConnect sharedInstance].selectedProfileName]; 
    6288} 
    6389 
     
    77103    KeywordCell *cell = (KeywordCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    78104    if (cell == nil) { 
    79         cell = [[[KeywordCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
     105                cell = [[[KeywordCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease]; 
    80106    } 
    81107        NSMutableDictionary *uiItem = [[uiArray objectAtIndex:indexPath.row] retain]; 
     
    124150        editController = [[KeywordEditController alloc]  
    125151                                                                                         initWithNibName:@"KeywordEdit" bundle:[NSBundle mainBundle]]; 
    126         editController.caller = self; 
     152        editController.delegate = self; 
    127153        NSDictionary *theKeyword = [self selectRecordInSetUsingId:[[uiArray objectAtIndex:indexPath.row] 
    128154                                                                                                                          objectForKey:@"id"]]; 
     
    162188} 
    163189 
     190- (void)dataDidLoadForController:(UIViewController *)controller { 
     191        // TODO: fix this controller to conform to the new stuff 
     192} 
     193 
     194- (NSString *)domain { 
     195        return ([self.delegate domain]); 
     196} 
     197 
    164198#pragma mark ------ UI Methods and Json Delegates 
    165199 
     
    170204        editController = [[KeywordEditController alloc]  
    171205                                          initWithNibName:@"KeywordEdit" bundle:[NSBundle mainBundle]]; 
    172         editController.caller = self; 
     206        editController.delegate = self; 
    173207        [editController presentViewForRecord:nil];       
    174208} 
     
    183217        navBar.topItem.rightBarButtonItem = buttonEdit; 
    184218        [theTable setEditing:NO animated:YES]; 
    185         //keywordTableHeight = kRowHeight; 
     219        //keywordTableHeight = kKRowHeight; 
    186220        [theTable reloadData]; 
    187221}        
     
    210244                        [self.uiArray addObject:[self uiItemFromJsonItem:aRec]]; 
    211245                } 
     246                [self.delegate dataDidLoadForController:self]; 
    212247                [self.theTable reloadData]; 
    213248        } else { 
     
    320355         
    321356        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 
    322         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 
     357        [requestData setObject:[self.delegate domain] forKey:@"domain"]; 
    323358        [requestData setObject:[VIPConnect sharedInstance].selectedProfileId forKey:@"profileId"]; 
    324359         
     
    376411                [newConn setConnectionUrl:[newConn urlFromAction:@"addkeyword"]]; 
    377412                NSMutableDictionary *newRequestData = [[NSMutableDictionary dictionaryWithObjectsAndKeys: 
    378                                                                                            [aRec objectForKey:@"domain"], @"domain", 
     413                                                                                           [self.delegate domain], @"domain", 
    379414                                                                                           [thePrimary objectForKey:@"key"], @"type", 
    380415                                                                                           [thePrimary objectForKey:@"value"], @"value", 
     
    397432         
    398433        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:3] retain]; 
    399         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 
     434        [requestData setObject:[self.delegate domain] forKey:@"domain"]; 
    400435        [requestData setObject:[aRec objectForKey:@"keywords"] forKey:@"keywords"]; 
    401436        if (newId) { 
     
    437472         
    438473        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 
    439         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 
     474        [requestData setObject:[self.delegate domain] forKey:@"domain"]; 
    440475        [requestData setObject:idsToDelete forKey:@"idList"]; 
    441476         
     
    470505                 
    471506                NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 
    472                 [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 
     507                [requestData setObject:[self.delegate domain] forKey:@"domain"]; 
    473508                 
    474509                [conn setPayload:requestData]; 
  • apps/iphone/my.tel/trunk/Classes/LocationViewController.h

    r535 r589  
    2727        IBOutlet MKMapView *theMap; 
    2828        TelMapAnnotation *markerTel; 
     29        id <TelControllerDelegate> delegate; 
    2930@private 
    3031        BOOL gpsLocIsAvailable; 
     
    3233        NSInteger moveToGPSButtonIndex; 
    3334        NSInteger moveToTelButtonIndex; 
     35        BOOL didPreload; 
    3436} 
    3537 
     38+ (LocationViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload; 
     39- (void)resetData; 
    3640- (void)recenterMap; 
    3741- (void)updateUILocationWithJson:(NSDictionary *)parsedJson; 
     
    5660@property (nonatomic, retain) IBOutlet MKMapView *theMap; 
    5761@property (nonatomic, retain) TelMapAnnotation *markerTel; 
     62@property (retain) id delegate; 
    5863 
    5964@end 
  • apps/iphone/my.tel/trunk/Classes/LocationViewController.m

    r535 r589  
    99#import "LocationViewController.h" 
    1010 
     11@interface LocationViewController (PrivateMethods) 
     12- (void)setDidPreload:(BOOL)preload; 
     13@end; 
     14 
    1115@implementation LocationViewController 
    1216 
     
    2024@synthesize theMap; 
    2125@synthesize markerTel; 
     26@synthesize delegate; 
     27 
     28#pragma mark - 
     29#pragma mark Designated initializer 
     30 
     31+ (LocationViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload { 
     32        LocationViewController *theC = [[[LocationViewController alloc] initWithNibName:@"TabLoc" bundle:nil] autorelease]; 
     33        theC.delegate = aDelegate; 
     34        [theC resetData]; 
     35        if (preload) { 
     36                [theC.view setNeedsLayout]; 
     37                [theC getLocation]; 
     38        } 
     39        [theC setDidPreload:preload]; 
     40        theC.title = @"Map"; 
     41        return theC;     
     42} 
     43 
     44- (void)setDidPreload:(BOOL)preload { 
     45        didPreload = preload; 
     46} 
    2247 
    2348#pragma mark ------ Standard View Controller Methods 
     
    2651    [super viewDidLoad]; 
    2752        theMap.delegate = self; 
     53        [MyCLController sharedInstance].delegate = self; 
     54} 
     55 
     56- (void)viewWillAppear:(BOOL)animated { 
     57        [super viewWillAppear:animated]; 
     58        // Don't get the data if we preloaded 
     59        if (didPreload) { 
     60                didPreload = NO; 
     61        } else { 
     62                [self getLocation]; 
     63        } 
     64} 
     65 
     66- (void)viewDidAppear:(BOOL)animated { 
     67        [super viewDidAppear:animated]; 
     68        self.theMap.showsUserLocation = YES; 
     69} 
     70 
     71- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
     72    // Return YES for supported orientations 
     73    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
     74} 
     75 
     76- (void)didReceiveMemoryWarning { 
     77    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview 
     78    // Release anything that's not essential, such as cached data 
     79} 
     80 
     81 
     82- (void)dealloc { 
     83    [super dealloc]; 
     84} 
     85 
     86- (void)resetData { 
    2887        gpsLocIsAvailable = NO; 
    2988        telLocIsAvailable = NO; 
    3089        buttonDeleteLoc.enabled = telLocIsAvailable; 
    31         [MyCLController sharedInstance].delegate = self; 
    32         [self getLocation];      
    33 } 
    34  
    35 - (void)viewWillAppear:(BOOL)animated { 
    36         [super viewWillAppear:animated]; 
    37         [self getLocation];      
    38 } 
    39  
    40 - (void)viewDidAppear:(BOOL)animated { 
    41         [super viewDidAppear:animated]; 
    42         self.theMap.showsUserLocation = YES; 
    43 } 
    44  
    45 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    46     // Return YES for supported orientations 
    47     return (interfaceOrientation == UIInterfaceOrientationPortrait); 
    48 } 
    49  
    50 - (void)didReceiveMemoryWarning { 
    51     [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview 
    52     // Release anything that's not essential, such as cached data 
    53 } 
    54  
    55  
    56 - (void)dealloc { 
    57     [super dealloc]; 
    5890} 
    5991 
     
    134166                CLLocationCoordinate2D newCoords = {[jsonLat floatValue], [jsonLong floatValue]}; 
    135167                self.markerTel = [TelMapAnnotation annotationWithCoordinate:newCoords]; 
    136                 self.markerTel.title = [VIPConnect sharedInstance].selectedDomain; 
     168                self.markerTel.title = [self.delegate domain]; 
    137169                [self.theMap addAnnotation:markerTel]; 
    138170                [self.theMap selectAnnotation:markerTel animated:YES]; 
     
    151183        } 
    152184        buttonDeleteLoc.enabled = telLocIsAvailable; 
     185        [self.delegate dataDidLoadForController:self]; 
    153186} 
    154187 
     
    212245         
    213246        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 
    214         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     247        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    215248         
    216249        [conn setPayload:requestData]; 
     
    235268        NSString *currLong = [NSString stringWithFormat:@"%f", centerPointCoord.longitude]; 
    236269        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; 
    237         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     270        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    238271        [requestData setObject:self.apiId forKey:@"apiId"]; 
    239272        [requestData setObject:currLat forKey:@"latitude"]; 
     
    259292         
    260293        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 
    261         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     294        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    262295        [requestData setObject:self.apiId forKey:@"apiId"]; 
    263296         
  • apps/iphone/my.tel/trunk/Classes/LoginViewController.h

    r299 r589  
    1010#import "VIPConnect.h" 
    1111#import "DnsResolver.h" 
    12 #import "MainTabBarController.h" 
     12#import "DomainViewController.h" 
    1313 
    1414@interface LoginViewController : UIViewController <UITextFieldDelegate> { 
    15     IBOutlet MainTabBarController *tabBarController; 
    1615        IBOutlet UITextField *fieldUser; 
    1716        IBOutlet UITextField *fieldPassword; 
     
    3635- (IBAction)didClickSignUpButton:(id)sender; 
    3736 
    38 @property (nonatomic, retain) IBOutlet MainTabBarController *tabBarController; 
    3937@property (nonatomic, retain) IBOutlet UITextField *fieldUser; 
    4038@property (nonatomic, retain) IBOutlet UITextField *fieldPassword; 
  • apps/iphone/my.tel/trunk/Classes/LoginViewController.m

    r313 r589  
    1111@implementation LoginViewController 
    1212 
    13 @synthesize tabBarController; 
    1413@synthesize fieldUser; 
    1514@synthesize fieldPassword; 
     
    9291        username = fieldUser.text; 
    9392        password = fieldPassword.text; 
    94         if ([fieldDomain.text hasSuffix:@".vip.tel"]) { 
    95                 domainName = [NSString stringWithString:fieldDomain.text]; 
    96         } else if ([fieldDomain.text hasSuffix:@".tel"]) { 
     93        if ([fieldDomain.text hasSuffix:@".tel"]) { 
    9794                domainName = [NSString stringWithString:fieldDomain.text]; 
    9895        } else { 
     
    137134- (void)postLoginSetup:(NSDictionary *)parsedJson { 
    138135        if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 
    139                 // TODO: Put the VIPConnect stuff also in the TelPostLoginDelegate protocol 
    140                 if (! [VIPConnect sharedInstance].selectedDomain) { 
    141                         NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    142                         [VIPConnect sharedInstance].selectedDomain = [defaults stringForKey:@"domainName"]; 
    143                 } 
    144                 if (! [VIPConnect sharedInstance].selectedProfileId) { 
    145                         [[VIPConnect sharedInstance] retrieveProfiles]; 
    146                         [[VIPConnect sharedInstance] grabActiveProfile]; 
    147                 } 
    148                  
    149136                if ([[parsedJson valueForKey:@"usedTempPassword"] integerValue] == 1) { 
    150137                        // Don't support temp passwords, consider login ok 
    151138                } 
    152                 [[UIApplication sharedApplication].keyWindow addSubview:tabBarController.view]; 
     139                //[[UIApplication sharedApplication].keyWindow addSubview:tabBarController.view]; 
     140                DomainViewController *theDVC = [DomainViewController controllerForDomain:[self.delegate domain]]; 
     141                UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:theDVC]; 
     142                [[UIApplication sharedApplication].keyWindow addSubview:navC.view]; 
    153143                [self.view removeFromSuperview]; 
    154144        } else { 
     
    170160        if (!aDomain) 
    171161                return nil; 
    172         if ([aDomain hasSuffix:@".vip.tel"]) { 
    173                 return @"https://demo.vip.tel/g2/json"; 
    174         } 
    175162        // try to autoprovision apiRootUrl 
    176163        NSMutableArray *naptrArray = [[NSMutableArray arrayWithCapacity:1] retain]; 
     
    218205    [[NSNotificationCenter defaultCenter] removeObserver:self 
    219206                                                                                                        name:UITextFieldTextDidEndEditingNotification object:nil];  
    220     [tabBarController release]; 
    221207    [super dealloc]; 
    222208} 
  • apps/iphone/my.tel/trunk/Classes/ProfileViewController.h

    r254 r589  
    1212#import "Profile.h" 
    1313#import "TextHeader.h" 
     14#import "ProfileRecordsViewController.h" 
    1415 
    15 @protocol ProfileViewDelegate 
    16  
    17 - (void)didActivateProfile:(NSString *)profileId; 
    18  
    19 @end 
    20  
    21 @interface ProfileViewController : UIViewController 
    22                                                         <UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate> { 
     16@interface ProfileViewController : UITableViewController 
     17<UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate, TelControllerDelegate> { 
    2318        NSString *apiId; 
    2419        NSMutableArray *profilesArray;  // retrieved raw JSON data (also used as the datasource array) 
     
    2823        UIImage *iconactiveselected; 
    2924 
    30         IBOutlet UITableView *theTable; 
    31         IBOutlet UILabel *domainLabel; 
    32         IBOutlet UIBarButtonItem *buttonSelect; 
    33         IBOutlet UIBarButtonItem *buttonActivate; 
    34         IBOutlet UIBarButtonItem *buttonRename; 
    35         IBOutlet UIBarButtonItem *buttonNew; 
    36         IBOutlet UIBarButtonItem *buttonDelete; 
    37         id <ProfileViewDelegate> delegate; 
     25        id <TelControllerDelegate> delegate; 
     26@private 
     27        BOOL didPreload; 
    3828} 
    3929 
     30+ (ProfileViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload; 
    4031- (void)updateUITableWithJson:(NSDictionary *)parsedJson; 
    4132 
    4233- (void)listProfiles; 
    43 - (void)activateProfile:(NSDictionary *)aProf; 
    4434- (void)createProfile:(NSString *)aProfName; 
    45 - (NSDecimalNumber *)updateProfile:(NSString *)aProfName forId:(NSString *)anId ; 
    46 - (void)deleteProfile:(NSDictionary *)aProf; 
     35- (NSDecimalNumber *)updateProfile:(NSString *)aProfName forId:(NSString *)anId; 
     36- (void)deleteProfile:(NSDictionary *)aProf atIndex:(NSIndexPath *)indexPath; 
     37 
     38- (IBAction)didClickAdd:(id)sender; 
    4739 
    4840@property (nonatomic, retain) NSString *apiId; 
    4941@property (nonatomic, retain) NSMutableArray *profilesArray; 
    50  
    51 - (IBAction)didClickDone:(id)sender; 
    52 - (IBAction)didClickSelect:(id)sender; 
    53 - (IBAction)didClickActivate:(id)sender; 
    54 - (IBAction)didClickRename:(id)sender; 
    55 - (IBAction)didClickAdd:(id)sender; 
    56 - (IBAction)didClickDelete:(id)sender; 
    57  
    58 @property (nonatomic, retain) IBOutlet UITableView *theTable; 
    59 @property (nonatomic, retain) IBOutlet UILabel *domainLabel; 
    60 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonSelect; 
    61 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonActivate; 
    62 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonRename; 
    63 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonNew; 
    64 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonDelete; 
    6542@property (retain) id delegate; 
    6643 
  • apps/iphone/my.tel/trunk/Classes/ProfileViewController.m

    r535 r589  
    99#import "ProfileViewController.h" 
    1010 
     11@interface ProfileViewController (PrivateMethods) 
     12- (void)setDidPreload:(BOOL)preload; 
     13@end; 
    1114 
    1215@implementation ProfileViewController 
     
    1518@synthesize profilesArray; 
    1619 
    17 @synthesize theTable; 
    18 @synthesize domainLabel; 
    19 @synthesize buttonSelect; 
    20 @synthesize buttonActivate; 
    21 @synthesize buttonRename; 
    22 @synthesize buttonNew; 
    23 @synthesize buttonDelete; 
    2420@synthesize delegate; 
    2521 
    26 #define kAlertAddId 1 
    27 #define kAlertRenameId 2 
     22#pragma mark - 
     23#pragma mark Designated initializer 
     24 
     25+ (ProfileViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload { 
     26        ProfileViewController *theC = [[[ProfileViewController alloc] initWithStyle:UITableViewStylePlain] autorelease]; 
     27        theC.delegate = aDelegate; 
     28        theC.profilesArray = [NSMutableArray arrayWithCapacity:10]; 
     29        if (preload) { 
     30                [theC listProfiles]; 
     31        } 
     32        [theC setDidPreload:preload]; 
     33        return theC;     
     34} 
     35 
     36- (void)setDidPreload:(BOOL)preload { 
     37        didPreload = preload; 
     38} 
    2839 
    2940#pragma mark ------ Standard View Controller Methods 
     
    3142- (void)viewDidLoad { 
    3243    [super viewDidLoad]; 
    33         self.profilesArray = [NSMutableArray arrayWithCapacity:10]; 
    34         [self listProfiles]; 
    35          
     44         
     45        self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
     46                                                                                                                                                                                   target:self 
     47                                                                                                                                                                                   action:@selector(didClickAdd:)] 
     48                                                                                          autorelease]; 
     49        self.title = @"Profiles"; 
    3650        // Load the icons for the table view 
    3751        NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"iconinactive" ofType:@"png"]; 
     
    4660 
    4761- (void)viewWillAppear:(BOOL)animated { 
    48         [domainLabel setText:[VIPConnect sharedInstance].selectedDomain]; 
     62        [super viewWillAppear:animated]; 
     63        // Don't get the data if we preloaded 
     64        if (didPreload) { 
     65                didPreload = NO; 
     66        } else { 
     67                [self listProfiles]; 
     68        } 
    4969} 
    5070 
     
    7595 
    7696- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 
    77         return [[VIPConnect sharedInstance] topDomainFromDomain:[VIPConnect sharedInstance].selectedDomain]; 
     97        return [[VIPConnect sharedInstance] topDomainFromDomain:[self.delegate domain]]; 
    7898} 
    7999 
     
    122142 
    123143- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    124         [buttonSelect setEnabled:YES]; 
    125         [buttonActivate setEnabled:YES]; 
    126         [buttonRename setEnabled:YES]; 
    127         [buttonDelete setEnabled:YES]; 
    128 } 
    129  
    130 /* 
    131 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    132         return 60; 
    133 } 
    134 */ 
     144        [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
     145        NSDictionary *aProf = [[profilesArray objectAtIndex:indexPath.row] retain]; 
     146        ProfileRecordsViewController *prVC = [ProfileRecordsViewController controllerWithProfile:aProf delegate:self preload:YES]; 
     147        [aProf release]; 
     148        [self.navigationController pushViewController:prVC animated:YES]; 
     149} 
     150 
     151- (void)setEditing:(BOOL)editing animated:(BOOL)animated { 
     152        if (editing) { 
     153                self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
     154                                                                                                                                                                                                target:self 
     155                                                                                                                                                                                                action:@selector(didClickAdd:)] 
     156                                                                                                  autorelease]; 
     157        } else { 
     158                self.navigationItem.leftBarButtonItem = nil; 
     159        } 
     160} 
     161 
     162- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
     163                                                                                        forRowAtIndexPath:(NSIndexPath *)indexPath { 
     164        if (editingStyle == UITableViewCellEditingStyleDelete) { 
     165                NSDictionary *aProf = [profilesArray objectAtIndex:indexPath.row]; 
     166                [self deleteProfile:aProf atIndex:indexPath]; 
     167        }                
     168} 
     169 
     170#pragma mark - 
     171#pragma mark TelControllerDelegate Methods 
     172 
     173- (void)dataDidLoadForController:(UIViewController *)controller { 
     174        if ([controller isMemberOfClass:[ProfileRecordsViewController class]]) { 
     175                // Something changed with the selected profile, let's refresh our list 
     176                [self listProfiles]; 
     177        } 
     178} 
     179 
     180- (NSString *)domain { 
     181        // return the actual domain from its domain controller 
     182        return ([self.delegate domain]); 
     183} 
    135184 
    136185#pragma mark ------ UI Methods and Json Delegates 
    137  
    138 - (IBAction)didClickDone:(id)sender { 
    139         [self.view removeFromSuperview]; 
    140 } 
    141  
    142 - (IBAction)didClickSelect:(id)sender { 
    143         NSIndexPath *selectedPath = [theTable indexPathForSelectedRow]; 
    144         NSDictionary *aProf = [[profilesArray objectAtIndex:selectedPath.row] retain]; 
    145         [VIPConnect sharedInstance].selectedProfileId = [aProf objectForKey:@"id"]; 
    146         [VIPConnect sharedInstance].selectedProfileName = [aProf objectForKey:@"name"]; 
    147         [theTable reloadData]; 
    148         [aProf release]; 
    149 } 
    150  
    151 - (IBAction)didClickActivate:(id)sender { 
    152         NSIndexPath *selectedPath = [theTable indexPathForSelectedRow]; 
    153         if (selectedPath) { 
    154                 NSDictionary *aProf = [[profilesArray objectAtIndex:selectedPath.row] retain]; 
    155                 [self activateProfile:aProf]; 
    156                 [aProf release]; 
    157                 [self listProfiles]; 
    158         } 
    159 } 
    160  
    161 - (IBAction)didClickRename:(id)sender { 
    162         NSIndexPath *selectedPath = [theTable indexPathForSelectedRow]; 
    163         if (selectedPath) { 
    164                 NSDictionary *aProf = [[profilesArray objectAtIndex:selectedPath.row] retain]; 
    165                 AlertRenameView *alert = [AlertRenameView alloc]; 
    166                 [[alert initWithTitle:@"Edit Profile Name"  
    167                                           message:@"\n\n" 
    168                                          delegate:self 
    169                         cancelButtonTitle:@"Cancel" 
    170                         otherButtonTitles:@"OK", nil] autorelease]; 
    171                 alert.alertId = [NSNumber numberWithInt:kAlertRenameId]; 
    172                 alert.uiStringField.text = [aProf objectForKey:@"name"]; 
    173                 [alert show]; 
    174                 [aProf release]; 
    175         } 
    176 } 
    177186 
    178187- (IBAction)didClickAdd:(id)sender { 
     
    183192                cancelButtonTitle:@"Cancel" 
    184193                otherButtonTitles:@"OK", nil] autorelease]; 
    185         alert.alertId = [NSNumber numberWithInt:kAlertAddId]; 
     194        alert.alertId = [NSNumber numberWithInt:0]; 
    186195        alert.uiStringField.text = @""; 
    187196        [alert show]; 
    188 } 
    189  
    190 - (IBAction)didClickDelete:(id)sender { 
    191         NSIndexPath *selectedPath = [theTable indexPathForSelectedRow]; 
    192         if (selectedPath) { 
    193                 NSDictionary *aProf = [profilesArray objectAtIndex:selectedPath.row]; 
    194                 [self deleteProfile:aProf]; 
    195                 [self listProfiles]; 
    196         } 
    197197} 
    198198 
     
    206206                [self.profilesArray setArray:(NSArray *)[parsedJson valueForKey:@"profileList"]]; 
    207207                [VIPConnect sharedInstance].profilesInDomain = self.profilesArray; 
    208         } else { 
     208                [self.delegate dataDidLoadForController:self]; 
     209                [self.tableView reloadData]; 
     210        } else { 
     211                [self.tableView reloadData]; 
    209212                [Profile throwJsonErrorAlert:parsedJson]; 
    210213        } 
    211         [self.theTable reloadData]; 
    212  
    213214} 
    214215 
     
    224225                return; 
    225226        } 
    226         if ([aV.alertId integerValue] == kAlertAddId) { 
    227                 [self createProfile:aV.uiStringField.text]; 
    228                 [self listProfiles]; 
    229                 return; 
    230         } 
    231         if ([aV.alertId integerValue] == kAlertRenameId) { 
    232                 NSIndexPath *selectedPath = [theTable indexPathForSelectedRow]; 
    233                 if (selectedPath) { 
    234                         NSDictionary *aProf = [profilesArray objectAtIndex:selectedPath.row]; 
    235                         [self updateProfile:aV.uiStringField.text forId:[aProf objectForKey:@"id"]]; 
    236                         [self listProfiles]; 
    237                 } 
    238                 return; 
    239         } 
     227        [self createProfile:aV.uiStringField.text]; 
     228        [self listProfiles]; 
     229        return; 
    240230} 
    241231 
     
    265255        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 
    266256        VIPConnect *cVip = [VIPConnect sharedInstance]; 
    267         [requestData setObject:[cVip topDomainFromDomain:cVip.selectedDomain] forKey:@"domainName"]; 
     257        [requestData setObject:[cVip topDomainFromDomain:[self.delegate domain]] forKey:@"domainName"]; 
    268258         
    269259        [conn setPayload:requestData]; 
    270260        [conn performLookup:TRUE]; 
    271261        [requestData release]; 
    272 } 
    273  
    274 - (void)activateProfile:(NSDictionary *)aProf { 
    275 //      inputProfile = { 
    276 //      domainName: "cartman.tel", 
    277 //      profileId: 23 
    278 //      }; 
    279 //       
    280 //      successResult = { 
    281 //      success: true, 
    282 //      actionMessages: ["profile activated", 
    283 //                                       "2nd message here", 
    284 //                                       "3rd message here"] 
    285 //      };       
    286          
    287         if (!aProf) { 
    288                 return; 
    289         } 
    290         [aProf retain]; 
    291         Profile *conn = [[[Profile alloc] init] autorelease]; 
    292         [conn setTheDelegate:[VIPConnect sharedInstance]]; 
    293         [conn setActionSel:@selector(doNothing:)]; 
    294         [conn setConnectionUrl:[conn urlFromAction:@"activateprofile"]]; 
    295          
    296         NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 
    297         VIPConnect *cVip = [VIPConnect sharedInstance]; 
    298         [requestData setObject:[cVip topDomainFromDomain:cVip.selectedDomain] forKey:@"domainName"]; 
    299         [requestData setObject:[aProf objectForKey:@"id"] forKey:@"profileId"]; 
    300          
    301         [conn setPayload:requestData]; 
    302         NSDictionary *parsedJson = [conn performLookup:FALSE]; 
    303         [requestData release]; 
    304         if ([[parsedJson valueForKey:@"success"] integerValue] == 0) { 
    305                 [Profile throwJsonErrorAlert:parsedJson]; 
    306         } else { 
    307                 [delegate didActivateProfile:[aProf objectForKey:@"id"]]; 
    308         }                
    309         [aProf release]; 
    310262} 
    311263 
     
    322274                 
    323275                NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; 
    324                 [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     276                [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    325277                [requestData setObject:newProfileId forKey:@"profileId"]; 
    326278                [requestData setObject:@"0" forKey:@"apiId"]; 
     
    362314        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:3] retain]; 
    363315        VIPConnect *cVip = [VIPConnect sharedInstance]; 
    364         [requestData setObject:[cVip topDomainFromDomain:cVip.selectedDomain] forKey:@"domainName"]; 
     316        [requestData setObject:[cVip topDomainFromDomain:[self.delegate domain]] forKey:@"domainName"]; 
    365317        if (anId) {     // update name of existing profile 
    366318                [requestData setObject:anId forKey:@"profileId"]; 
     
    376328                [Profile throwJsonErrorAlert:parsedJson]; 
    377329        } else { 
    378                 // if it's the selected profile, update our cache 
    379                 if ([[VIPConnect sharedInstance].selectedProfileId isEqual:anId]) { 
    380                         [VIPConnect sharedInstance].selectedProfileName = aProfName; 
    381                 } 
    382330                newProfileId = [parsedJson valueForKey:@"profileId"]; 
    383331        }                
     
    386334} 
    387335 
    388 - (void)deleteProfile:(NSDictionary *)aProf { 
     336- (void)deleteProfile:(NSDictionary *)aProf atIndex:(NSIndexPath *)indexPath { 
    389337//      inputProfile = { 
    390338//              domainName: "cartman.tel", 
     
    412360        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 
    413361        VIPConnect *cVip = [VIPConnect sharedInstance]; 
    414         [requestData setObject:[cVip topDomainFromDomain:cVip.selectedDomain] forKey:@"domainName"]; 
     362        [requestData setObject:[cVip topDomainFromDomain:[self.delegate domain]] forKey:@"domainName"]; 
    415363        [requestData setObject:[aProf objectForKey:@"id"] forKey:@"profileId"]; 
    416364         
     
    421369        if ([[parsedJson valueForKey:@"success"] integerValue] == 0) { 
    422370                [Profile throwJsonErrorAlert:parsedJson]; 
     371        } else { 
     372                [self.profilesArray removeObjectAtIndex:indexPath.row]; 
     373        [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
    423374        } 
    424375        [aProf release]; 
  • apps/iphone/my.tel/trunk/Classes/RecordCell.h

    r149 r589  
    1717        IBOutlet UILabel *labelValue; 
    1818        IBOutlet UIImageView *labelImage; 
    19         IBOutlet UISwitch *switchEnabled; 
     19        BOOL canBeDisabled;     // if yes, put checkmark and allow disabling 
     20        BOOL enabledInProfile; 
    2021} 
    2122 
     
    2526@property (nonatomic, retain) UILabel *labelValue; 
    2627@property (nonatomic, retain) UIImageView *labelImage; 
    27 @property (nonatomic, retain) UISwitch *switchEnabled; 
    28  
    29 - (IBAction)setEnabledState:(id)sender; 
     28@property (nonatomic) BOOL canBeDisabled; 
     29@property (nonatomic) BOOL enabledInProfile; 
    3030 
    3131@end 
  • apps/iphone/my.tel/trunk/Classes/RecordCell.m

    r535 r589  
    1010 
    1111#ifndef kRowHeight 
    12 #define kRowHeight 54.0 
     12#define kRowHeight 52.0 
    1313#endif 
    1414 
    15 #define kFontSize 14 
     15#define kFontSize 12 
     16#define kMarginSize 3 
    1617 
    1718@implementation RecordCell 
     
    2223@synthesize labelValue; 
    2324@synthesize labelImage; 
    24 @synthesize switchEnabled; 
     25@synthesize canBeDisabled; 
     26@dynamic enabledInProfile; 
    2527 
    2628- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 
     
    3335                labelValue = nil; 
    3436                labelImage = nil; 
    35                 switchEnabled = nil; 
     37                canBeDisabled = NO; 
    3638                 
    3739                self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
     
    4850        // label.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.7]; 
    4951        label.backgroundColor = [UIColor clearColor]; 
    50         label.font = [UIFont systemFontOfSize:kFontSize-2]; 
    51                 label.textColor = [UIColor blueColor]; 
     52        label.font = [UIFont systemFontOfSize:kFontSize]; 
     53                label.textColor = [UIColor darkGrayColor]; 
    5254                self.labelLabel = label; 
    5355        [self.contentView addSubview:label];             
     
    5759        label.backgroundColor = [UIColor clearColor]; 
    5860        label.font = [UIFont systemFontOfSize:kFontSize]; 
    59                 self.labelValue = label; 
     61                label.textColor = [UIColor blueColor]; 
     62                self.labelValue = label; 
    6063        [self.contentView addSubview:label];     
    6164        [label release]; 
     
    6770        [img release]; 
    6871                 
    69                 UISwitch *sw = [[UISwitch alloc] initWithFrame:CGRectZero]; 
    70                 self.switchEnabled = sw; 
    71                 [self.contentView addSubview:sw];        
    72                 [sw release]; 
    73                 // Make sure we update the underlying data source when the cell turned on/off 
    74                 [switchEnabled addTarget:self.target 
    75                                                   action:@selector(switchedEnabling:) 
    76                                 forControlEvents:UIControlEventValueChanged]; 
    77                 // and also change the look 
    78                 [switchEnabled addTarget:self 
    79                                                   action:@selector(setEnabledState:) 
    80                                 forControlEvents:UIControlEventValueChanged]; 
    81                  
     72                self.enabledInProfile = TRUE; 
    8273        } 
    8374    return self; 
     
    9485    CGRect iconImageRect = self.contentView.bounds; 
    9586    iconImageRect.size = CGSizeMake(30.0, 30.0); 
    96     iconImageRect = CGRectOffset(iconImageRect,3,(kRowHeight-iconImageRect.size.height)/2); 
    97     labelImage.frame = iconImageRect; 
     87        //      Choose the below to vertically align the icon in the cell 
     88        //      That won't work if the cell is dynamically resized 
     89        //  iconImageRect = CGRectOffset(iconImageRect,kMarginSize,(kRowHeight-iconImageRect.size.height)/2); 
     90        iconImageRect = CGRectOffset(iconImageRect,kMarginSize,kMarginSize); 
     91   labelImage.frame = iconImageRect; 
    9892     
    99     // position the text label in the content rect 
     93    // position the text labels in the content rect 
    10094    CGRect labelRect = contentRect; 
    101     labelRect.origin.x = contentRect.origin.x+36; 
    102     labelRect.origin.y = contentRect.origin.y+3; 
     95    labelRect.origin.x = contentRect.origin.x+kMarginSize+labelImage.frame.size.width+kMarginSize; 
     96    labelRect.origin.y = contentRect.origin.y+kMarginSize; 
    10397        labelRect.size.height = labelService.font.pointSize+2; 
    10498        labelRect.size.width = 250; 
    10599    labelService.frame = labelRect; 
    106         labelRect.origin.y = labelRect.origin.y+labelRect.size.height+4; 
     100        labelRect.origin.y = labelRect.origin.y+labelRect.size.height+2; 
    107101    labelValue.frame = labelRect; 
    108         labelRect.origin.y = labelService.frame.origin.y; 
    109102        labelRect.size.height = labelLabel.font.pointSize+2; 
    110         labelRect.size.width = 120; 
    111         labelRect.origin.x = contentRect.origin.x + contentRect.size.width - labelRect.size.width; 
     103        labelRect.origin.y = labelRect.origin.y+labelRect.size.height+2; 
     104//      labelRect.size.width = 120; 
     105//      labelRect.origin.x = contentRect.origin.x + contentRect.size.width - labelRect.size.width; 
    112106        labelLabel.frame = labelRect; 
    113         labelLabel.textAlignment = UITextAlignmentRight; 
    114          
    115         //position the switch icon 
    116         if (self.editing) { 
    117                 CGRect switchFrame = switchEnabled.frame; 
    118                 switchFrame.origin.x = contentRect.origin.x     + contentRect.size.width/2 - switchEnabled.frame.size.width/2; 
    119                 switchFrame.origin.y = contentRect.origin.y + contentRect.size.height - switchEnabled.frame.size.height - 5; 
    120                 [switchEnabled setFrame:switchFrame]; 
    121         } 
    122         switchEnabled.hidden = !self.editing;    
    123         labelLabel.hidden = self.editing; 
    124107} 
    125108 
     
    138121*/ 
    139122 
    140 - (IBAction)setEnabledState:(id)sender { 
    141         // User changed the enabled state 
    142         // Change look and feel if enabled or disabled 
    143         if ([switchEnabled isOn]) { 
     123- (BOOL)enabledInProfile { 
     124        return enabledInProfile; 
     125} 
     126 
     127- (void)setEnabledInProfile:(BOOL)isEnabled { 
     128        if (canBeDisabled) { 
     129                enabledInProfile = isEnabled; 
     130        } else { 
     131                enabledInProfile = TRUE; 
     132        } 
     133 
     134        if (enabledInProfile) { 
    144135                [labelImage setContentMode:UIViewContentModeTop]; 
    145136                [labelService setTextColor:[UIColor blackColor]]; 
    146                 [labelLabel setTextColor:[UIColor blueColor]]; 
    147                 [labelValue setTextColor:[UIColor blackColor]]; 
     137                [labelLabel setTextColor:[UIColor darkGrayColor]]; 
     138                [labelValue setTextColor:[UIColor blueColor]]; 
    148139        } else { 
    149140                [labelImage setContentMode:UIViewContentModeBottom]; 
    150141                [labelService setTextColor:[UIColor grayColor]]; 
    151142                [labelLabel setTextColor:[UIColor grayColor]]; 
    152                 [labelValue setTextColor:[UIColor grayColor]]; 
     143                [labelValue setTextColor:[UIColor grayColor]];           
    153144        } 
    154145} 
    155  
    156146@end 
  • apps/iphone/my.tel/trunk/Classes/RecordEditController.h

    r263 r589  
    1717 
    1818- (void)didStoreRecord:(NSDictionary *)aRec; 
     19- (NSString *)domain; 
    1920 
    2021@end 
     
    2223@interface RecordEditController : UIViewController 
    2324<RecordGroupsDelegate, UIPickerViewDataSource, UIPickerViewDelegate, UITextFieldDelegate> { 
    24         IBOutlet UIBarButtonItem *barHeader; 
    25         IBOutlet UIBarButtonItem *barButtonSave; 
    2625        IBOutlet UIPickerView *rPicker; 
    2726        IBOutlet UITextField *rValue; 
    2827        IBOutlet UITextField *rLabel; 
    29         IBOutlet UISwitch *rVisibility; 
    3028        IBOutlet UIButton *buttonPrivacy; 
    3129        id <RecordEditDelegate> delegate; 
    3230@private 
     31        NSMutableDictionary *_record; 
    3332        NSMutableArray *sArrKey; 
    3433        NSMutableArray *sArrVal; 
    3534        NSMutableArray *liArrKey; 
    3635        NSMutableArray *liArrVal; 
    37         NSMutableDictionary *theRecord; 
    3836        NSDictionary *naptrValuePlaceholders; 
     37        UIResponder *currentResponder; 
    3938} 
    4039 
    41 - (void) setPickerCol1:(NSDictionary *)pickerData1 col2:(NSDictionary *)pickerData1; 
    42 - (void)presentViewForRecord:(NSDictionary *)aRec; 
     40+ (RecordEditController *)controllerWithServiceKeys:(NSDictionary *)skeysDict lihKeys:(NSDictionary *)liDict; 
    4341- (void)setStateForTerminal:(BOOL)isTerminal; 
    4442- (void)setStateForButtonPrivacy; 
     
    5250- (void)storeNTNaptrRecord; 
    5351 
    54 @property (nonatomic, retain) IBOutlet UIBarButtonItem *barHeader; 
    55 @property (nonatomic, retain) IBOutlet UIBarButtonItem *barButtonSave; 
     52@property (nonatomic, copy) NSDictionary *record; 
    5653@property (nonatomic, retain) IBOutlet UIPickerView *rPicker; 
    5754@property (nonatomic, retain) IBOutlet UITextField *rValue; 
    5855@property (nonatomic, retain) IBOutlet UITextField *rLabel; 
    59 @property (nonatomic, retain) IBOutlet UISwitch *rVisibility; 
    6056@property (nonatomic, retain) IBOutlet UIButton *buttonPrivacy; 
    61 @property (retain) id delegate; 
     57@property (retain) id <RecordEditDelegate> delegate; 
    6258@end 
  • apps/iphone/my.tel/trunk/Classes/RecordEditController.m

    r504 r589  
    1111#import "RecordEditController.h" 
    1212 
    13 #define kRTransitionDuration    0.3 
    14  
    15 #define kNTNLabelLength 100             // NTN label length             TODO: verify with engineers 
    16 #define kTLabelLength 20                // Terminal label length 
     13#define kNTNLabelLength 255             // NTN label length 
     14#define kTLabelLength   255             // Terminal label length 
     15 
     16@interface RecordEditController (PrivateMethods) 
     17 
     18- (void) setPickerCol1:(NSDictionary *)pickerData1 col2:(NSDictionary *)pickerData1; 
     19 
     20@end 
    1721 
    1822@implementation RecordEditController 
    1923 
    20 @synthesize barHeader; 
    21 @synthesize barButtonSave; 
     24@dynamic record; 
    2225@synthesize rPicker; 
    2326@synthesize rValue; 
    2427@synthesize rLabel; 
    25 @synthesize rVisibility; 
    2628@synthesize buttonPrivacy; 
    2729@synthesize delegate; 
    2830 
    29 #pragma mark ----- Calling methods 
    30  
    31 - (void)presentViewForRecord:(NSDictionary *)aRec { 
    32         [theRecord release]; 
    33         if (!aRec) { // new 
    34                 barHeader.title = @"New Item"; 
    35                 rValue.text = @""; 
    36                 rLabel.text = @""; 
    37                 rVisibility.on = TRUE; 
    38                 theRecord = [[NSMutableDictionary dictionaryWithObjectsAndKeys: 
    39                                          @"0",                                                                                  @"apiId", 
    40                                          [VIPConnect sharedInstance].selectedDomain,    @"domainName", 
    41                                          [NSArray arrayWithObject:@"voice"],                    @"serviceKeys", 
    42                                          @"",                                                                                   @"label", 
    43                                          [NSArray array],                                                               @"locations", 
    44                                          [NSArray array],                                                               @"profiles", 
    45                                          [NSArray array],                                                               @"groups", 
    46                                           @"1",                                                                                 @"terminal", 
    47                                          nil] retain]; 
    48         } else { // edit 
    49                 theRecord = [[NSMutableDictionary dictionaryWithDictionary:aRec] retain]; 
    50                 barHeader.title = @"Edit Item"; 
    51                 [theRecord setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
    52                 // An NTN may not have the below items 
    53                 if ([[theRecord objectForKey:@"label"] isKindOfClass:[NSNull class]]) 
    54                         [theRecord setObject:@"" forKey:@"label"]; 
    55                 if ([[theRecord objectForKey:@"locations"] isKindOfClass:[NSNull class]]) 
    56                         [theRecord setObject:[NSArray array] forKey:@"locations"]; 
    57                 if ([[theRecord objectForKey:@"serviceKeys"] isKindOfClass:[NSNull class]]) { 
    58                         if ([[theRecord objectForKey:@"terminal"] integerValue] == 0) { 
    59                                 [theRecord setObject:[NSArray arrayWithObject:@"ntn"] forKey:@"serviceKeys"]; 
    60                         } else { 
    61                                 [theRecord setObject:[NSArray arrayWithObject:@"voice"] forKey:@"serviceKeys"]; 
    62                         } 
    63                 } 
    64                 if ([[theRecord objectForKey:@"profiles"] isKindOfClass:[NSNull class]]) 
    65                         [theRecord setObject:[NSArray array] forKey:@"profiles"]; 
    66                 if ([[theRecord objectForKey:@"groups"] isKindOfClass:[NSNull class]]) 
    67                         [theRecord setObject:[NSArray array] forKey:@"groups"]; 
    68                  
    69                 rValue.text = [theRecord objectForKey:@"value"]; 
    70                 rLabel.text = [theRecord objectForKey:@"label"]; 
    71                 if ([(NSArray *)[theRecord objectForKey:@"profiles"] containsObject:[VIPConnect sharedInstance].selectedProfileId]) { 
    72                         rVisibility.on = TRUE; 
    73                 } else { 
    74                         rVisibility.on = FALSE; 
    75                 } 
    76         } 
    77         // We only respect the first LIH and service types. 
    78         NSString *theService = [(NSArray *)[theRecord objectForKey:@"serviceKeys"] objectAtIndex:0]; 
    79         NSString *theLi; 
    80         if ([(NSArray *)[theRecord objectForKey:@"locations"] count] == 0) { 
    81                 theLi = @""; 
    82         } else { 
    83                 theLi = [(NSArray *)[theRecord objectForKey:@"locations"] objectAtIndex:0]; 
    84         } 
    85          
    86         [rPicker selectRow:[sArrKey indexOfObject:theService] inComponent:0 animated:NO]; 
    87         [rPicker selectRow:[liArrKey indexOfObject:theLi] inComponent:1 animated:NO]; 
    88         [self viewWillAppear:YES]; 
    89         [self setStateForTerminal:[[theRecord objectForKey:@"terminal"] boolValue]]; 
    90         // Insert our view at the absolute top 
    91         [[UIApplication sharedApplication].keyWindow addSubview:self.navigationController.view]; 
    92         // Set up the animation 
    93     CATransition *animation = [CATransition animation]; 
    94     [animation setDelegate:self]; 
    95      
    96         [animation setType:kCATransitionMoveIn]; 
    97         [animation setSubtype:kCATransitionFromRight]; 
    98      
    99     // Set the duration and timing function of the transtion -- duration is passed in as a parameter, use ease in/ease out as the timing function 
    100     [animation setDuration:kRTransitionDuration]; 
    101     [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 
    102      
    103     [[[UIApplication sharedApplication].keyWindow layer] addAnimation:animation forKey:@"kEditAnimation"]; 
    104 } 
     31#pragma mark - 
     32#pragma mark Designated Initializer 
     33 
     34+ (RecordEditController *)controllerWithServiceKeys:(NSDictionary *)skeysDict lihKeys:(NSDictionary *)liDict { 
     35        RecordEditController *theC = [[[RecordEditController alloc] initWithNibName:@"RecordEdit" bundle:nil] autorelease]; 
     36        [theC setPickerCol1:skeysDict col2:liDict]; 
     37        [theC setRecord:nil]; 
     38        return theC; 
     39} 
     40 
     41#pragma mark - 
     42#pragma mark Record management 
     43 
     44- (void)setRecord:(NSDictionary *)aRecord { 
     45        if (_record) [_record release]; 
     46        if (aRecord == nil) { 
     47                _record = nil; 
     48        } else { 
     49                _record = [NSMutableDictionary dictionaryWithDictionary:aRecord]; 
     50                [_record retain]; 
     51        } 
     52} 
     53 
     54- (NSDictionary *)record { 
     55        return (NSDictionary *)_record; 
     56} 
     57 
     58 
     59#pragma mark - 
     60#pragma mark Set Pickers 
    10561 
    10662- (void)setPickerCol1:(NSDictionary *)pickerData1 col2:(NSDictionary *)pickerData2 { 
     
    10864        NSUInteger i, count; 
    10965 
     66        [sArrKey release]; 
     67        [sArrVal release]; 
     68        [liArrKey release]; 
     69        [liArrVal release]; 
     70         
     71        sArrKey = [[NSMutableArray arrayWithCapacity:30] retain]; 
     72        sArrVal = [[NSMutableArray arrayWithCapacity:30] retain]; 
     73        liArrKey = [[NSMutableArray arrayWithCapacity:10] retain]; 
     74        liArrVal = [[NSMutableArray arrayWithCapacity:10] retain]; 
     75         
    11076        // Do first column 
    11177        // First set the keys and related strings 
    11278        [sArrKey setArray:[pickerData1 allKeys]]; 
    113         [sArrVal removeAllObjects]; 
    11479        for (NSString *aK in sArrKey) { 
    11580                [sArrVal addObject:[pickerData1 objectForKey:aK]]; 
     
    13095        // Same for second column, but also add a "None" entry 
    13196        [liArrKey setArray:[pickerData2 allKeys]]; 
    132         [liArrVal removeAllObjects]; 
    13397        for (NSString *aK in liArrKey) { 
    13498                [liArrVal addObject:[pickerData2 objectForKey:aK]]; 
     
    153117- (void)viewDidLoad { 
    154118    [super viewDidLoad]; 
    155         sArrKey = [[NSMutableArray arrayWithCapacity:30] retain]; 
    156         sArrVal = [[NSMutableArray arrayWithCapacity:30] retain]; 
    157         liArrKey = [[NSMutableArray arrayWithCapacity:10] retain]; 
    158         liArrVal = [[NSMutableArray arrayWithCapacity:10] retain]; 
     119        self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 
     120                                                                                                                                                                                  target:self 
     121                                                                                                                                                                                  action:@selector(didClickCancel:)] autorelease]; 
     122        self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave 
     123                                                                                                                                                                                   target:self 
     124                                                                                                                                                                                   action:@selector(didClickSave:)] autorelease]; 
    159125        [buttonPrivacy setTitle:@" This item is public" 
    160126                                   forState:UIControlStateDisabled]; 
     
    166132 
    167133- (void)viewWillAppear:(BOOL)animated { 
    168         [self setStateForButtonPrivacy]; 
     134        if (_record == nil) { // new 
     135                self.title = @"New Item"; 
     136                rValue.text = @""; 
     137                rLabel.text = @""; 
     138                _record = [[NSMutableDictionary dictionaryWithObjectsAndKeys: 
     139                                                  @"0",                                                                                 @"apiId", 
     140                                                  [self.delegate domain],                                               @"domainName", 
     141                                                  [NSArray arrayWithObject:@"voice"],                   @"serviceKeys", 
     142                                                  @"",                                                                                  @"label", 
     143                                                  [NSArray array],                                                              @"locations", 
     144                                                  [NSArray array],                                                              @"profiles", 
     145                                                  [NSArray array],                                                              @"groups", 
     146                                                  @"1",                                                                                 @"terminal", 
     147                                                  nil] retain]; 
     148        } else { // edit 
     149                self.title = @"Edit Item"; 
     150                [_record setObject:[self.delegate domain] forKey:@"domainName"]; 
     151                // An NTN may not have the below items 
     152                if ([[_record objectForKey:@"label"] isKindOfClass:[NSNull class]]) 
     153                        [_record setObject:@"" forKey:@"label"]; 
     154                if ([[_record objectForKey:@"locations"] isKindOfClass:[NSNull class]]) 
     155                        [_record setObject:[NSArray array] forKey:@"locations"]; 
     156                if ([[_record objectForKey:@"serviceKeys"] isKindOfClass:[NSNull class]]) { 
     157                        if ([[_record objectForKey:@"terminal"] integerValue] == 0) { 
     158                                [_record setObject:[NSArray arrayWithObject:@"ntn"] forKey:@"serviceKeys"]; 
     159                        } else { 
     160                                [_record setObject:[NSArray arrayWithObject:@"voice"] forKey:@"serviceKeys"]; 
     161                        } 
     162                } 
     163                if ([[_record objectForKey:@"profiles"] isKindOfClass:[NSNull class]]) 
     164                        [_record setObject:[NSArray array] forKey:@"profiles"]; 
     165                if ([[_record objectForKey:@"groups"] isKindOfClass:[NSNull class]]) 
     166                        [_record setObject:[NSArray array] forKey:@"groups"]; 
     167                 
     168                rValue.text = [_record objectForKey:@"value"]; 
     169                rLabel.text = [_record objectForKey:@"label"]; 
     170        } 
     171        // We only respect the first LIH and service types. 
     172        NSString *theService = [(NSArray *)[_record objectForKey:@"serviceKeys"] objectAtIndex:0]; 
     173        NSString *theLi; 
     174        if ([(NSArray *)[_record objectForKey:@"locations"] count] == 0) { 
     175                theLi = @""; 
     176        } else { 
     177                theLi = [(NSArray *)[_record objectForKey:@"locations"] objectAtIndex:0]; 
     178        } 
     179         
     180        [rPicker selectRow:[sArrKey indexOfObject:theService] inComponent:0 animated:NO]; 
     181        [rPicker selectRow:[liArrKey indexOfObject:theLi] inComponent:1 animated:NO]; 
     182        [self setStateForTerminal:[[_record objectForKey:@"terminal"] boolValue]]; 
    169183} 
    170184 
     
    182196 
    183197- (void)dealloc { 
     198        if (_record) [_record release]; 
    184199        [sArrKey release]; 
    185200        [sArrVal release]; 
     
    194209- (IBAction)didClickCancel:(id)sender { 
    195210        [self slideViewForEditing:NO]; 
    196         [self.navigationController.view removeFromSuperview]; 
     211        [self.navigationController popViewControllerAnimated:YES]; 
    197212} 
    198213 
     
    201216        // servicekey and LI are set when the user selects the pickerViews 
    202217        // apiId and domainName are set at the start in presentView 
    203         [theRecord setObject:rValue.text forKey:@"value"]; 
    204         [theRecord setObject:rLabel.text forKey:@"label"]; 
    205  
    206         VIPConnect *vipSI = [VIPConnect sharedInstance]; 
    207         NSMutableArray *newProfilesArray = [NSMutableArray arrayWithArray:[theRecord objectForKey:@"profiles"]]; 
    208         [newProfilesArray removeObjectIdenticalTo:vipSI.selectedProfileId]; 
    209         if (rVisibility.on) { 
    210                 [newProfilesArray addObject:vipSI.selectedProfileId]; 
    211         } 
    212         [theRecord setObject:newProfilesArray forKey:@"profiles"]; 
    213          
     218        [_record setObject:rValue.text forKey:@"value"]; 
     219        [_record setObject:rLabel.text forKey:@"label"]; 
     220 
    214221        // Store the record 
    215222        if ([rPicker numberOfRowsInComponent:1] == 0) { // ntn 
     
    221228 
    222229- (IBAction)didClickPrivacy:(id)sender { 
    223         RecordGroupsController *rGC = [RecordGroupsController controllerForRecord:theRecord groups:nil]; 
     230        RecordGroupsController *rGC = [RecordGroupsController controllerForRecord:_record groups:nil]; 
    224231        rGC.delegate = self; 
    225232        [self.navigationController pushViewController:rGC animated:YES]; 
     
    253260        [conn setActionSel:@selector(doNothing:)]; 
    254261        [conn setConnectionUrl:[conn urlFromAction:@"storerecord"]]; 
    255         [conn setPayload:theRecord]; 
     262        [conn setPayload:_record]; 
    256263        NSDictionary *parsedJson = [conn performLookup:FALSE]; 
    257264         
    258265        if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 
    259                 [delegate didStoreRecord:theRecord]; 
     266                [delegate didStoreRecord:_record]; 
    260267                [self slideViewForEditing:NO]; 
    261                 [self.navigationController.view removeFromSuperview]; 
     268                [self.navigationController popViewControllerAnimated:YES]; 
    262269        } else { 
    263270                [JsonConnection throwJsonErrorAlert:parsedJson]; 
     
    285292         */ 
    286293         
    287         NSMutableDictionary *ntnRec = [NSMutableDictionary dictionaryWithDictionary:theRecord]; 
     294        NSMutableDictionary *ntnRec = [NSMutableDictionary dictionaryWithDictionary:_record]; 
    288295        [ntnRec removeObjectForKey:@"locations"]; 
    289296        //[ntnRec setObject:[NSArray array] forKey:@"groups"]; 
     
    305312         
    306313        if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 
    307                 [delegate didStoreRecord:theRecord]; 
     314                [delegate didStoreRecord:_record]; 
    308315                [self slideViewForEditing:NO]; 
    309                 [self.navigationController.view removeFromSuperview]; 
     316                [self.navigationController popViewControllerAnimated:YES]; 
    310317        } else { 
    311318                [JsonConnection throwJsonErrorAlert:parsedJson]; 
     
    316323 
    317324- (void)setStateForTerminal:(BOOL)isTerminal { 
    318         // Disable label for now on ntn. 
    319         // TODO: re-enable when labels allowed for ntn 
    320         if (isTerminal) { 
    321                 rLabel.placeholder = @"Short description"; 
    322                 rLabel.enabled = YES; 
    323                 rVisibility.enabled = YES; 
    324                 buttonPrivacy.enabled = YES; 
    325                 [self setStateForButtonPrivacy]; 
    326         } else { 
    327                 rLabel.text = @""; 
    328                 rLabel.enabled = NO; 
    329                 rLabel.placeholder = @" -- disabled --"; 
    330                 rVisibility.on = YES; 
    331                 rVisibility.enabled = NO; 
    332                 buttonPrivacy.enabled = YES;    // TODO: See if privacy works for NTN 
    333                 [self setStateForButtonPrivacy]; 
    334         } 
     325        // NTNs now have all the features of terminal NAPTRs including labels 
     326        //      if (isTerminal) { 
     327        //      } else { 
     328        //      } 
     329        rLabel.placeholder = @""; 
     330        rLabel.enabled = YES; 
     331        buttonPrivacy.enabled = YES; 
     332        [self setStateForButtonPrivacy]; 
    335333        [self.view setNeedsLayout]; 
    336334        [self.view setNeedsDisplay]; 
     
    338336 
    339337- (void)setStateForButtonPrivacy { 
    340         NSUInteger numGroups = [(NSArray *)[theRecord objectForKey:@"groups"] count]; 
     338        NSUInteger numGroups = [(NSArray *)[_record objectForKey:@"groups"] count]; 
    341339        if (numGroups == 0) { 
    342                 [buttonPrivacy setTitle:@" This item is public" 
     340                [buttonPrivacy setTitle:@" Public item" 
    343341                                           forState:(UIControlStateNormal & UIControlStateHighlighted)]; 
    344342        } else { 
    345343                if (numGroups == 1) 
    346                         [buttonPrivacy setTitle:@" Member of 1 privacy group" 
     344                        [buttonPrivacy setTitle:@" In 1 group" 
    347345                                                   forState:(UIControlStateNormal & UIControlStateHighlighted)]; 
    348346                else 
    349                         [buttonPrivacy setTitle:[NSString stringWithFormat:@" Member of %d privacy groups", numGroups] 
     347                        [buttonPrivacy setTitle:[NSString stringWithFormat:@" In %d groups", numGroups] 
    350348                                                   forState:(UIControlStateNormal & UIControlStateHighlighted)]; 
    351349        } 
     
    353351 
    354352- (void)slideViewForEditing:(BOOL)isEditing { 
     353        self.navigationItem.rightBarButtonItem.enabled = !isEditing;    // disable the "Save" button until done editing 
    355354        if (isEditing) { 
    356355                if (self.view.frame.origin.y >=0) { 
     
    366365                        self.view.frame = newFrame; 
    367366                } 
     367                // resign firstResponder status 
     368                [currentResponder resignFirstResponder]; 
     369                currentResponder = nil; 
    368370        } 
    369371} 
     
    371373#pragma mark ------ RecordGroupsDelegate methods 
    372374- (void)replaceGroupsForRecord:(NSDictionary *)aRecord withGroups:(NSArray *)groupsIdList { 
    373         [theRecord setObject:groupsIdList forKey:@"groups"]; 
     375        [_record setObject:groupsIdList forKey:@"groups"]; 
     376} 
     377 
     378- (NSString *)domain { 
     379        // request the domain from the calling controller 
     380        return [self.delegate domain]; 
    374381} 
    375382 
    376383#pragma mark ------ TextField delegate methods 
    377384- (void)textFieldDidBeginEditing:(UITextField *)textField { 
     385        currentResponder = textField; 
    378386        [self slideViewForEditing:YES]; 
    379387        return; 
     
    383391} 
    384392- (BOOL)textFieldShouldReturn:(UITextField *)textField { 
    385         [textField resignFirstResponder]; 
    386393        [self slideViewForEditing:NO]; 
    387394        return YES; 
     
    389396- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range 
    390397                                                                                        replacementString:(NSString *)string { 
    391         // Check length of fields. Terminal labels should be very short 
    392398        if (textField == rLabel) { 
     399                NSUInteger labelLength; 
    393400                if ([rPicker numberOfRowsInComponent:1] == 0) { // ntn 
    394                         if ((range.location + range.length) >= kNTNLabelLength) 
    395                                 return NO; 
     401                        labelLength = kNTNLabelLength; 
    396402                } else { 
    397                         if ((range.location + range.length) >= kTLabelLength) 
    398                                 return NO; 
     403                        labelLength = kTLabelLength; 
     404                } 
     405                if (([textField.text length] - range.length + [string length]) > labelLength) { 
     406                        return NO; 
    399407                } 
    400408        } 
     
    414422        if (component == 1) { 
    415423                if (!self.navigationController.view.superview) {        // View hasn't been loaded yet, check for ntn directly from record 
    416                         if ([[theRecord objectForKey:@"terminal"] integerValue] == 0) 
     424                        if ([[_record objectForKey:@"terminal"] integerValue] == 0) 
    417425                                return 0; 
    418426                } else { 
     
    429437- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 
    430438        if (component == 0) { 
    431                 [theRecord setObject:[NSArray arrayWithObject:[sArrKey objectAtIndex:row]] 
     439                [_record setObject:[NSArray arrayWithObject:[sArrKey objectAtIndex:row]] 
    432440                                          forKey:@"serviceKeys"]; 
    433441                rValue.placeholder = [naptrValuePlaceholders objectForKey:[sArrKey objectAtIndex:row]]; 
     
    448456        if (component == 1) { 
    449457                if (row > -1) { // Not an ntn 
    450                         [theRecord setObject:[NSArray arrayWithObject:[liArrKey objectAtIndex:row]] 
     458                        [_record setObject:[NSArray arrayWithObject:[liArrKey objectAtIndex:row]] 
    451459                                                  forKey:@"locations"]; 
    452460                } else { 
    453461                        // this shouldn't happen 
    454                         [theRecord removeObjectForKey:@"locations"]; 
     462                        [_record removeObjectForKey:@"locations"]; 
    455463                } 
    456464        } 
  • apps/iphone/my.tel/trunk/Classes/RecordGroupsController.h

    r263 r589  
    1515// if groupIdList is an empty array, record is public 
    1616- (void)replaceGroupsForRecord:(NSDictionary *)aRecord withGroups:(NSArray *)groupsIdList; 
     17- (NSString *)domain; 
    1718 
    1819@end 
  • apps/iphone/my.tel/trunk/Classes/RecordGroupsController.m

    r535 r589  
    2626#pragma mark ------ Initializer 
    2727 
    28 + (RecordGroupsController *)controllerForRecord:(NSDictionary *)aRec groups:(NSArray *)aGroupsArray{ 
     28+ (RecordGroupsController *)controllerForRecord:(NSDictionary *)aRec groups:(NSArray *)aGroupsArray { 
    2929        if (!aRec) 
    3030                return nil; 
     
    112112         
    113113        NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 
    114         [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 
     114        [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 
    115115         
    116116        [conn setPayload:requestData]; 
  • apps/iphone/my.tel/trunk/Classes/RecordViewController.h

    r535 r589  
    1313#import "RecordEditController.h" 
    1414 
    15 @interface RecordViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, RecordEditDelegate> { 
     15@interface RecordViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource, RecordEditDelegate> { 
    1616        NSMutableDictionary *skeysDict; // Localized Service Keys (voice -> Voice Call) 
    1717        NSMutableDictionary *liDict;    // Localized Location indicators (x-home -> Home) 
     
    2121        NSMutableArray *uiArray;                // the data to show in a UITable 
    2222         
    23         CGFloat recordTableHeight;      // Record table height: kRowHeight if not editing, add kRowHeightEditIncrease if editing 
     23        CGFloat recordTableHeight;      // Record table height: kRowHeight by default 
    2424         
    25         IBOutlet UITableView *theTable; 
    26         IBOutlet UIBarButtonItem *buttonAdd; 
    27         IBOutlet UIBarButtonItem *buttonEdit; 
    28         IBOutlet UIBarButtonItem *buttonDone; 
    29         IBOutlet UINavigationBar *navBar; 
    30         IBOutlet RecordEditController *editController; 
     25        id <TelControllerDelegate> delegate; 
    3126@private 
    32         UINavigationController *editNavController;      // Navigation controller for the editing 
     27        RecordEditController *editController; 
    3328        NSUInteger buttonEditCount; 
     29        BOOL didPreload; 
    3430} 
     31 
     32+ (RecordViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload; 
     33+ (NSDictionary *)imageMappings; 
     34 
     35- (void)displayEditingForRecord:(NSDictionary *)aRec; 
    3536 
    3637- (NSDictionary *)selectRecordInSetUsingId:(NSString *)anId; 
     
    3839- (void)updateUITableWithJson:(NSDictionary *)parsedJson; 
    3940- (NSMutableDictionary *)uiItemFromJsonItem:(NSDictionary *)jsonItem; 
    40 - (void)fillServicesDict:(NSDictionary *)parsedJson; 
    41 - (void)fillLocationsDict:(NSDictionary *)parsedJson; 
    4241 
    4342- (void)getRecords; 
     
    4544- (void)deleteRecords:(NSDictionary *)aRec; 
    4645- (void)orderRecords; 
    47 - (void)enableRecords; 
    48 - (void)disableRecords; 
    49 - (void)getServiceKeys:(BOOL)fromNetwork; 
    50 - (void)getLocations:(BOOL)fromNetwork; 
    51 - (void)displayEditingForRecord:(NSDictionary *)aRec; 
     46 
     47- (IBAction)switchedEnabling:(id)sender; 
    5248 
    5349@property (nonatomic, retain) NSMutableDictionary *skeysDict; 
     
    5854@property (nonatomic, retain) NSMutableArray *uiArray; 
    5955 
    60 - (IBAction)switchedEnabling:(id)sender; 
    61 - (IBAction)addRecord:(id)sender; 
    62 - (IBAction)editTable:(id)sender; 
    63 - (IBAction)doneEditingTable:(id)sender; 
    64  
    65 @property (nonatomic, retain) IBOutlet UITableView *theTable; 
    66 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonAdd; 
    67 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonEdit; 
    68 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonDone; 
    69 @property (nonatomic, retain) IBOutlet UINavigationBar *navBar; 
    7056@property (nonatomic, retain) IBOutlet RecordEditController *editController; 
     57@property (retain) id delegate; 
    7158 
    7259@end 
  • apps/iphone/my.tel/trunk/Classes/RecordViewController.m

    r536 r589  
    99#import "RecordViewController.h" 
    1010 
    11 #define kRowHeight 47.0 
     11#define kRowHeight 52.0 
    1212#define kRowHeightEditIncrease 35.0 
    1313 
    1414static NSDictionary *imageMappings; 
     15 
     16@interface RecordViewController (PrivateMethods) 
     17- (void)setDidPreload:(BOOL)preload; 
     18@end; 
    1519 
    1620@implementation RecordViewController 
     
    2327@synthesize uiArray; 
    2428 
    25 @synthesize theTable; 
    26 @synthesize buttonAdd; 
    27 @synthesize buttonEdit; 
    28 @synthesize buttonDone; 
    29 @synthesize navBar; 
    3029@synthesize editController; 
     30@synthesize delegate; 
     31 
     32#pragma mark - 
     33#pragma mark Designated initializer 
     34 
     35+ (RecordViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload { 
     36        RecordViewController *theC = [[[RecordViewController alloc] initWithNibName:@"TabNaptr" bundle:nil] autorelease]; 
     37        theC.delegate = aDelegate; 
     38        theC.skeysDict = [NSMutableDictionary dictionaryWithContentsOfFile: 
     39                                          [[NSBundle mainBundle] pathForResource:@"ServiceTypes" ofType:@"plist"]]; 
     40        theC.liDict = [NSMutableDictionary dictionaryWithContentsOfFile: 
     41                                   [[NSBundle mainBundle] pathForResource:@"LocationIndicators" ofType:@"plist"]]; 
     42        theC.recordsArray = [NSMutableArray arrayWithCapacity:20]; 
     43        theC.uiArray = [NSMutableArray arrayWithCapacity:20]; 
     44 
     45        if (preload) { 
     46                [theC getRecords]; 
     47        } 
     48        [theC setDidPreload:preload]; 
     49        return theC;     
     50} 
     51 
     52- (void)setDidPreload:(BOOL)preload { 
     53        didPreload = preload; 
     54} 
    3155 
    3256#pragma mark ------ Class variables access 
     
    76100- (void)viewDidLoad { 
    77101    [super viewDidLoad]; 
    78         [self getServiceKeys:NO]; 
    79         [self getLocations:NO]; 
    80         self.recordsArray = [NSMutableArray arrayWithCapacity:20]; 
    81         self.uiArray = [NSMutableArray arrayWithCapacity:20]; 
     102        self.title = @"Contact Items"; 
     103        self.navigationItem.rightBarButtonItem = self.editButtonItem; 
     104        self.tableView.allowsSelectionDuringEditing = YES;      // so that the insert cell can be selected 
    82105        recordTableHeight = kRowHeight; 
    83106        [[self class] imageMappings]; 
    84107} 
     108 
    85109- (void)viewWillAppear:(BOOL)animated { 
    86         // This triggers when switching tabs 
    87         self.title = navBar.topItem.title = [VIPConnect sharedInstance].selectedDomain; 
    88         [self getRecords]; 
     110        [super viewWillAppear:animated]; 
     111        // Don't get the data if we preloaded 
     112        if (didPreload) { 
     113                didPreload = NO; 
     114        } else { 
     115                [self getRecords]; 
     116        } 
    89117} 
    90118 
    91119- (void)dealloc { 
    92         [liDict release]; 
    93         [skeysDict release]; 
     120        self.liDict = nil; 
     121        self.skeysDict = nil; 
     122        self.apiId = nil; 
     123        self.recordsArray = nil; 
     124        self.uiArray = nil; 
     125        self.editController = nil; 
    94126        [imageMappings release]; 
    95127    [super dealloc]; 
     
    103135 
    104136- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 
    105         return [NSString stringWithFormat:@"Profile: %@", [VIPConnect sharedInstance].selectedProfileName]; 
     137        return @"All records"; 
    106138} 
    107139 
    108140- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    109     return [uiArray count]; 
     141        NSUInteger addRow = self.editing ? 1 : 0;       // put in the insert row when editing 
     142    return ([uiArray count] + addRow); 
    110143} 
    111144 
     
    116149         
    117150    static NSString *CellIdentifier = @"RecordCellIdentifier"; 
     151        static NSString *AddCellIdentifier = @"RecordAddCellIdentifier"; 
    118152     
    119     RecordCell *cell = (RecordCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    120     if (cell == nil) { 
    121         cell = [[[RecordCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease]; 
    122    } 
    123         NSMutableDictionary *uiItem = [[uiArray objectAtIndex:indexPath.row] retain]; 
    124         [cell.labelService setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"service"]]]; 
    125         [cell.labelLabel setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"label"]]]; 
    126         [cell.labelValue setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"value"]]]; 
    127          
    128         // Set the icon image 
    129         [cell.labelImage setImage:[UIImage imageNamed:(NSString *)[uiItem objectForKey:@"imageName"]]]; 
    130         //[cell.labelImage setBounds:CGRectMake(33.0, 5.0, 30.0, 30.0)]; 
    131  
    132         // Change look and feel if enabled or disabled 
    133         if ([[uiItem valueForKey:@"enabled"] integerValue] == 1) { 
    134                 [cell.labelImage setContentMode:UIViewContentModeTop]; 
    135                 [cell.labelService setTextColor:[UIColor blackColor]]; 
    136                 [cell.labelLabel setTextColor:[UIColor blueColor]]; 
    137                 [cell.labelValue setTextColor:[UIColor blackColor]]; 
    138                 [cell.switchEnabled setOn:TRUE]; 
    139         } else { 
    140                 [cell.labelImage setContentMode:UIViewContentModeBottom]; 
    141                 [cell.labelService setTextColor:[UIColor grayColor]]; 
    142                 [cell.labelLabel setTextColor:[UIColor grayColor]]; 
    143                 [cell.labelValue setTextColor:[UIColor grayColor]]; 
    144                 [cell.switchEnabled setOn:FALSE]; 
    145         } 
    146         if ([[uiItem valueForKey:@"terminal"] integerValue] == 1) { 
    147                 [cell.switchEnabled setEnabled:TRUE]; 
    148         } else { 
    149                 [cell.switchEnabled setEnabled:FALSE]; 
    150         } 
    151         // TODO: Overlay a small padlock image if the record is private 
    152  
    153         [uiItem release]; 
     153        RecordCell *cell; 
     154         
     155        if (self.editing && (indexPath.row == ([self tableView:tableView numberOfRowsInSection:indexPath.section]-1))) { 
     156                // we're in editing mode, show the last row as an insert row 
     157                cell = (RecordCell *)[tableView dequeueReusableCellWithIdentifier:AddCellIdentifier]; 
     158                if (cell == nil) { 
     159                        cell = [[[RecordCell alloc] initWithStyle:UITableViewCellStyleDefault 
     160                                                                                   reuseIdentifier:AddCellIdentifier] autorelease]; 
     161                        cell.accessoryType = cell.editingAccessoryType = UITableViewCellAccessoryNone; 
     162                        cell.textLabel.text = @"Add new contact item"; 
     163                        cell.textLabel.textColor = [UIColor blueColor]; 
     164                        cell.textLabel.font = [UIFont boldSystemFontOfSize:15]; 
     165                } 
     166        } else { 
     167                 
     168                cell = (RecordCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
     169                if (cell == nil) { 
     170                        cell = [[[RecordCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease]; 
     171                        cell.canBeDisabled = FALSE;             // When not handling profiles, don't allow enable/disable 
     172           } 
     173                NSMutableDictionary *uiItem = [[uiArray objectAtIndex:indexPath.row] retain]; 
     174                [cell.labelService setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"service"]]]; 
     175                [cell.labelLabel setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"label"]]]; 
     176                [cell.labelValue setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"value"]]]; 
     177                 
     178                // Set the icon image 
     179                [cell.labelImage setImage:[UIImage imageNamed:(NSString *)[uiItem objectForKey:@"imageName"]]]; 
     180                //[cell.labelImage setBounds:CGRectMake(33.0, 5.0, 30.0, 30.0)]; 
     181 
     182        //      cell.enabledInProfile = [[uiItem valueForKey:@"enabled"] boolValue]; 
     183        //      // Change look and feel if enabled or disabled 
     184        //      if ([[uiItem valueForKey:@"terminal"] integerValue] == 1) { 
     185        //              [cell.switchEnabled setEnabled:TRUE]; 
     186        //      } else { 
     187        //              [cell.switchEnabled setEnabled:FALSE]; 
     188        //      } 
     189                // TODO: Overlay a small padlock image if the record is private 
     190 
     191                [uiItem release]; 
     192        } 
    154193 
    155194        return cell; 
    156195} 
    157196 
     197- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
     198        if ([tableView cellForRowAtIndexPath:indexPath].editingStyle == UITableViewCellEditingStyleDelete) { 
     199                // Do not go into the record edit view when the table is in editing mode 
     200                return nil; 
     201        } 
     202        return indexPath; 
     203} 
     204 
    158205 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    159          if (tableView.editing) { 
    160                  // Don't go to the details screen for a record if we're editing the table 
    161                  [tableView deselectRowAtIndexPath:indexPath animated:NO]; 
     206         [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
     207         if ([tableView cellForRowAtIndexPath:indexPath].editingStyle == UITableViewCellEditingStyleInsert) { 
     208                 // we're inserting a row 
     209                 [tableView.dataSource tableView:tableView 
     210                                          commitEditingStyle:UITableViewCellEditingStyleInsert forRowAtIndexPath:indexPath]; 
    162211         } else { 
    163                  [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    164212                 NSDictionary *theRecord = [self selectRecordInSetUsingId:[[uiArray objectAtIndex:indexPath.row] 
    165213                                                                                                                                   objectForKey:@"apiId"]]; 
    166214                 [self displayEditingForRecord:theRecord]; 
     215                  
    167216         } 
    168217 } 
    169218 
     219- (void)setEditing:(BOOL)editing animated:(BOOL)animated { 
     220        [super setEditing:editing animated:animated]; 
     221        UITableView *tv = self.tableView; 
     222        [tv beginUpdates]; 
     223        NSArray *insertIndexPaths = [NSArray arrayWithObjects: 
     224                                                                 [NSIndexPath indexPathForRow:([self.recordsArray count]) 
     225                                                                                                        inSection:0], 
     226                                                                 nil]; 
     227        if (editing) { 
     228                [tv insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationTop]; 
     229        } else { 
     230                [tv deleteRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationTop]; 
     231                buttonEditCount = 3; 
     232                UIActivityIndicatorView *aiV = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; 
     233                [aiV startAnimating]; 
     234                UIBarButtonItem *savingButton = [[UIBarButtonItem alloc] initWithCustomView:aiV]; 
     235                [aiV release]; 
     236                self.navigationItem.rightBarButtonItem = savingButton; 
     237                [self orderRecords]; 
     238//              [tableView reloadData]; 
     239        } 
     240        [tv endUpdates]; 
     241} 
     242 
     243- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 
     244        if (self.editing) { 
     245                if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) { 
     246                        // We're in the last row, which is the insert row 
     247                        return UITableViewCellEditingStyleInsert; 
     248                } else { 
     249                        return UITableViewCellEditingStyleDelete; 
     250                } 
     251        } else { 
     252                return UITableViewCellEditingStyleNone; 
     253        } 
     254} 
     255 
    170256- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
    171257         
    172258        if (editingStyle == UITableViewCellEditingStyleDelete) { 
    173                 if (tableView.editing) { 
     259              &nb