diff --git a/Classes/BuschJaegerCallView.h b/Classes/BuschJaegerCallView.h index 2da642e54..dbb4c481d 100644 --- a/Classes/BuschJaegerCallView.h +++ b/Classes/BuschJaegerCallView.h @@ -29,27 +29,18 @@ @interface BuschJaegerCallView : UIViewController { @private - UIView* videoView; - UIButton* startCall; - UIButton* takeCall; - UIHangUpButton* decline; - UIHangUpButton* endOrRejectCall; - UIToggleButton* mute; - UIDigitButton* lights; - UIDigitButton* openDoor; - LinphoneChatRoom * chatRoom; VideoZoomHandler* videoZoomHandler; } @property (nonatomic, retain) IBOutlet UIView* videoView; -@property (nonatomic, retain) IBOutlet UIButton* startCall; -@property (nonatomic, retain) IBOutlet UIButton* takeCall; -@property (nonatomic, retain) IBOutlet UIHangUpButton* decline; -@property (nonatomic, retain) IBOutlet UIHangUpButton* endOrRejectCall; -@property (nonatomic, retain) IBOutlet UIToggleButton* mute; -@property (nonatomic, retain) IBOutlet UIDigitButton* lights; -@property (nonatomic, retain) IBOutlet UIDigitButton* openDoor; +@property (nonatomic, retain) IBOutlet UIButton* startCallButton; +@property (nonatomic, retain) IBOutlet UIButton* takeCallButton; +@property (nonatomic, retain) IBOutlet UIHangUpButton* declineButton; +@property (nonatomic, retain) IBOutlet UIHangUpButton* endOrRejectCallButton; +@property (nonatomic, retain) IBOutlet UIToggleButton* microButton; +@property (nonatomic, retain) IBOutlet UIDigitButton* lightsButton; +@property (nonatomic, retain) IBOutlet UIDigitButton* openDoorButton; - (IBAction)takeCall:(id)sender; - (IBAction)startCall:(id)sender; diff --git a/Classes/BuschJaegerCallView.m b/Classes/BuschJaegerCallView.m index ded0b0756..d681e5eaf 100644 --- a/Classes/BuschJaegerCallView.m +++ b/Classes/BuschJaegerCallView.m @@ -26,13 +26,13 @@ @implementation BuschJaegerCallView @synthesize videoView; -@synthesize startCall; -@synthesize takeCall; -@synthesize decline; -@synthesize endOrRejectCall; -@synthesize mute; -@synthesize lights; -@synthesize openDoor; +@synthesize startCallButton; +@synthesize takeCallButton; +@synthesize declineButton; +@synthesize endOrRejectCallButton; +@synthesize microButton; +@synthesize lightsButton; +@synthesize openDoorButton; - (void)didReceiveMemoryWarning { @@ -44,13 +44,13 @@ - (void)dealloc { [videoView release]; - [startCall release]; - [takeCall release]; - [decline release]; - [endOrRejectCall release]; - [mute release]; - [lights release]; - [openDoor release]; + [startCallButton release]; + [takeCallButton release]; + [declineButton release]; + [endOrRejectCallButton release]; + [microButton release]; + [lightsButton release]; + [openDoorButton release]; // Remove all observer [[NSNotificationCenter defaultCenter] removeObserver:self]; @@ -66,32 +66,32 @@ - (void)viewDidLoad { [super viewDidLoad]; - [openDoor setDigit:'1']; - [lights setDigit:'2']; - [mute setImage:[UIImage imageNamed:@"bj_mute_on.png"] forState:UIControlStateHighlighted | UIControlStateSelected]; + [openDoorButton setDigit:'1']; + [lightsButton setDigit:'2']; + [microButton setImage:[UIImage imageNamed:@"bj_mute_off.png"] forState:UIControlStateHighlighted | UIControlStateSelected]; /* init gradients */ { - UIColor* col1 = [UIColor colorWithRed:32.0/255 green:45.0/255 blue:62.0/255 alpha:1.0]; - UIColor* col2 = [UIColor colorWithRed:18.0/255 green:26.0/255 blue:41.0/255 alpha:1.0]; + UIColor* col1 = BUSCHJAEGER_NORMAL_COLOR; + UIColor* col2 = BUSCHJAEGER_NORMAL_COLOR2; - [BuschJaegerUtils createGradientForView:startCall withTopColor:col1 bottomColor:col2]; - [BuschJaegerUtils createGradientForView:openDoor withTopColor:col1 bottomColor:col2]; - [BuschJaegerUtils createGradientForView:lights withTopColor:col1 bottomColor:col2]; - [BuschJaegerUtils createGradientForView:mute withTopColor:col1 bottomColor:col2]; + [BuschJaegerUtils createGradientForButton:startCallButton withTopColor:col1 bottomColor:col2]; + [BuschJaegerUtils createGradientForButton:openDoorButton withTopColor:col1 bottomColor:col2]; + [BuschJaegerUtils createGradientForButton:lightsButton withTopColor:col1 bottomColor:col2]; + [BuschJaegerUtils createGradientForButton:microButton withTopColor:col1 bottomColor:col2]; } { - UIColor* col1 = [UIColor colorWithRed:153.0/255 green:48.0/255 blue:48.0/255 alpha:1.0]; - UIColor* col2 = [UIColor colorWithRed:66.0/255 green:15.0/255 blue:15.0/255 alpha:1.0]; + UIColor* col1 = BUSCHJAEGER_RED_COLOR; + UIColor* col2 = BUSCHJAEGER_RED_COLOR2; - [BuschJaegerUtils createGradientForView:endOrRejectCall withTopColor:col1 bottomColor:col2]; - [BuschJaegerUtils createGradientForView:decline withTopColor:col1 bottomColor:col2]; + [BuschJaegerUtils createGradientForButton:endOrRejectCallButton withTopColor:col1 bottomColor:col2]; + [BuschJaegerUtils createGradientForButton:declineButton withTopColor:col1 bottomColor:col2]; } { - UIColor* col1 = [UIColor colorWithRed:91.0/255 green:161.0/255 blue:89.0/255 alpha:1.0]; - UIColor* col2 = [UIColor colorWithRed:25.0/255 green:54.0/255 blue:24.0/255 alpha:1.0]; + UIColor* col1 = BUSCHJAEGER_GREEN_COLOR; + UIColor* col2 = BUSCHJAEGER_GREEN_COLOR; - [BuschJaegerUtils createGradientForView:takeCall withTopColor:col1 bottomColor:col2]; + [BuschJaegerUtils createGradientForView:takeCallButton withTopColor:col1 bottomColor:col2]; } linphone_core_set_native_video_window_id([LinphoneManager getLc],(unsigned long)videoView); @@ -123,11 +123,11 @@ name:kLinphoneCallUpdate object:nil]; - [startCall setHidden:NO]; - [takeCall setHidden:YES]; - [mute setHidden:NO]; - [decline setHidden:YES]; - [endOrRejectCall setHidden:YES]; + [startCallButton setHidden:NO]; + [takeCallButton setHidden:YES]; + [microButton setHidden:NO]; + [declineButton setHidden:YES]; + [endOrRejectCallButton setHidden:YES]; [videoView setHidden:YES]; if (!chatRoom) { @@ -172,6 +172,8 @@ return; } + [microButton update]; + switch (state) { case LinphoneCallIncomingReceived: { @@ -197,29 +199,29 @@ } - (void)displayIncomingCall:(LinphoneCall *)call { - [startCall setHidden:YES]; - [takeCall setHidden:NO]; - [mute setHidden:YES]; - [decline setHidden:NO]; - [endOrRejectCall setHidden:YES]; + [startCallButton setHidden:YES]; + [takeCallButton setHidden:NO]; + [microButton setHidden:YES]; + [declineButton setHidden:NO]; + [endOrRejectCallButton setHidden:YES]; [videoView setHidden:NO]; } - (void)displayInCall { - [startCall setHidden:YES]; - [takeCall setHidden:YES]; - [mute setHidden:NO]; - [decline setHidden:YES]; - [endOrRejectCall setHidden:NO]; + [startCallButton setHidden:YES]; + [takeCallButton setHidden:YES]; + [microButton setHidden:NO]; + [declineButton setHidden:YES]; + [endOrRejectCallButton setHidden:NO]; [videoView setHidden:NO]; } - (void)displayVideoCall { - [startCall setHidden:YES]; - [takeCall setHidden:YES]; - [mute setHidden:NO]; - [decline setHidden:YES]; - [endOrRejectCall setHidden:NO]; + [startCallButton setHidden:YES]; + [takeCallButton setHidden:YES]; + [microButton setHidden:NO]; + [declineButton setHidden:YES]; + [endOrRejectCallButton setHidden:NO]; [videoView setHidden:NO]; } diff --git a/Classes/BuschJaegerCallView.xib b/Classes/BuschJaegerCallView.xib index b7f3dd18e..e38409768 100644 --- a/Classes/BuschJaegerCallView.xib +++ b/Classes/BuschJaegerCallView.xib @@ -162,11 +162,11 @@ NSImage - bj_mute_on.png + bj_mute_off.png NSImage - bj_mute_off.png + bj_mute_on.png @@ -177,7 +177,6 @@ {{207, 0}, {73, 58}} - _NS:225 NO @@ -281,54 +280,6 @@ - - - startCall - - - - 66 - - - - takeCall - - - - 69 - - - - endOrRejectCall - - - - 70 - - - - mute - - - - 71 - - - - openDoor - - - - 72 - - - - lights - - - - 73 - videoView @@ -347,11 +298,59 @@ - decline + declineButton - 76 + 77 + + + + endOrRejectCallButton + + + + 78 + + + + lightsButton + + + + 79 + + + + openDoorButton + + + + 80 + + + + startCallButton + + + + 82 + + + + takeCallButton + + + + 83 + + + + microButton + + + + 84 @@ -424,43 +423,43 @@ 8 - OpenDoor + Open Door Button 10 - Light + Light Button 9 - Mute + Micro Button 43 - Decline call + Decline Call Button 6 - StartCall + Start Call Button 57 - AcceptCall + Accept Call Button 7 - StopCall + Stop Call Button @@ -493,16 +492,16 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin IBBuiltInLabel-Red - UIMuteButton + UIMicroButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin - + IBBuiltInLabel-Red - 76 + 84 @@ -524,42 +523,42 @@ - UIHangUpButton - UIHangUpButton - UIDigitButton - UIToggleButton - UIDigitButton - UIButton - UIButton + UIHangUpButton + UIHangUpButton + UIDigitButton + UIDigitButton + UIToggleButton + UIButton + UIButton UIView - - decline + + declineButton UIHangUpButton - - endOrRejectCall + + endOrRejectCallButton UIHangUpButton - - lights + + lightsButton UIDigitButton - - mute + + openDoorButton + UIDigitButton + + + speakerButton UIToggleButton - - openDoor - UIDigitButton - - - startCall + + startCallButton UIButton - - takeCall + + takeCallButton UIButton @@ -607,6 +606,14 @@ ./Classes/UILongTouchButton.h + + UIMicroButton + UIToggleButton + + IBProjectSource + ./Classes/UIMicroButton.h + + UIToggleButton UIButton diff --git a/Classes/BuschJaegerConfigParser.h b/Classes/BuschJaegerConfigParser.h index 11207853e..fe62b45e9 100644 --- a/Classes/BuschJaegerConfigParser.h +++ b/Classes/BuschJaegerConfigParser.h @@ -35,8 +35,9 @@ @property (readonly) NSMutableSet *outdoorStations; - (void)reset; +- (BOOL)loadFile:(NSString*)file; - (BOOL)saveFile:(NSString*)file; -- (BOOL)parseFile:(NSString*)file; - (BOOL)parseQRCode:(NSString*)data delegate:(id)delegate; ++ (NSString*)getRegexValue:(NSString*)regexString data:(NSString*)data; @end diff --git a/Classes/BuschJaegerConfigParser.m b/Classes/BuschJaegerConfigParser.m index ffb57c22a..b6be1be9d 100644 --- a/Classes/BuschJaegerConfigParser.m +++ b/Classes/BuschJaegerConfigParser.m @@ -109,35 +109,16 @@ return nil; } -- (void)parseOutdoorStation:(int)ID array:(NSArray*)array { - OutdoorStation *os = [[OutdoorStation alloc] initWithId:ID]; - NSString *param; - for(NSString *entry in array) { - if((param = [BuschJaegerConfigParser getRegexValue:@"^address=(.*)$" data:entry]) != nil) { - os.address = param; - } else if((param = [BuschJaegerConfigParser getRegexValue:@"^name=(.*)$" data:entry]) != nil) { - os.name = param; - } else if((param = [BuschJaegerConfigParser getRegexValue:@"^screenshot=(.*)$" data:entry]) != nil) { - os.screenshot = [param compare:@"yes" options:NSCaseInsensitiveSearch] || [param compare:@"true" options:NSCaseInsensitiveSearch]; - } else if((param = [BuschJaegerConfigParser getRegexValue:@"^surveillance=(.*)$" data:entry]) != nil) { - os.surveillance = [param compare:@"yes" options:NSCaseInsensitiveSearch] || [param compare:@"true" options:NSCaseInsensitiveSearch]; - } else if([[entry stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] != 0){ - [LinphoneLogger log:LinphoneLoggerWarning format:@"Unknown entry in outdoorstation_%d section: %@", ID, entry]; - } - } - [outdoorStations addObject:os]; -} - - (void)parseSection:(NSString*)section array:(NSArray*)array { - NSString *param; - if((param = [BuschJaegerConfigParser getRegexValue:@"^\\[outdoorstation_([\\d]+)\\]$" data:section]) != nil) { - [self parseOutdoorStation:[param intValue] array:array]; + id obj; + if((obj = [OutdoorStation parse:section array:array]) != nil) { + [outdoorStations addObject:obj]; } else { [LinphoneLogger log:LinphoneLoggerWarning format:@"Unknown section: %@", section]; } } -- (void)parseConfig:(NSString*)data delegate:(id)delegate { +- (BOOL)parseConfig:(NSString*)data delegate:(id)delegate { [LinphoneLogger log:LinphoneLoggerDebug format:@"%@", data]; NSArray *arr = [data componentsSeparatedByString:@"\n"]; NSString *last_section = nil; @@ -147,17 +128,17 @@ NSString *subStr = [arr objectAtIndex:i]; if([subStr hasPrefix:@"["]) { if([subStr hasSuffix:@"]"]) { - if(last_index != -1) { - NSArray *subArray = [NSArray arrayWithArray:[arr subarrayWithRange:NSMakeRange(last_index, i - last_index)]]; - [self parseSection:last_section array:subArray]; - } - last_section = subStr; - last_index = i + 1; + if(last_index != -1) { + NSArray *subArray = [NSArray arrayWithArray:[arr subarrayWithRange:NSMakeRange(last_index, i - last_index)]]; + [self parseSection:last_section array:subArray]; + } + last_section = subStr; + last_index = i + 1; } else { dispatch_async(dispatch_get_main_queue(), ^{ [delegate buschJaegerConfigParserError:NSLocalizedString(@"Invalid configuration file", nil)]; }); - return; + return FALSE; } } } @@ -169,6 +150,7 @@ dispatch_async(dispatch_get_main_queue(), ^{ [delegate buschJaegerConfigParserSuccess]; }); + return TRUE; } - (void)reset { @@ -176,12 +158,41 @@ } - (BOOL)saveFile:(NSString*)file { + NSMutableString *data = [NSMutableString string]; + for(OutdoorStation *os in outdoorStations) { + [data appendString:[os write]]; + } + + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsPath = [paths objectAtIndex:0]; + NSString *databaseDocumentPath = [documentsPath stringByAppendingPathComponent:file]; + + NSError *error; + if(![data writeToFile:databaseDocumentPath atomically:FALSE encoding:NSUTF8StringEncoding error:&error]) { + [LinphoneLogger log:LinphoneLoggerError format:@"Can't write BuschJaeger ini file: %@", [error localizedDescription]]; + return FALSE; + } return TRUE; } -- (BOOL)parseFile:(NSString*)file { +- (BOOL)loadFile:(NSString*)file { [self reset]; - return TRUE; + + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsPath = [paths objectAtIndex:0]; + NSString *databaseDocumentPath = [documentsPath stringByAppendingPathComponent:file]; + if ([fileManager fileExistsAtPath:databaseDocumentPath] == NO) { + [LinphoneLogger log:LinphoneLoggerError format:@"BuschJaeger ini file doesn't exist: %@", file]; + return FALSE; + } + NSError *error; + NSString *data = [NSString stringWithContentsOfFile:databaseDocumentPath encoding:NSUTF8StringEncoding error:&error]; + if(data == nil) { + [LinphoneLogger log:LinphoneLoggerError format:@"Can't read BuschJaeger ini file: %@", [error localizedDescription]]; + return FALSE; + } + return [self parseConfig:data delegate:nil];; } - (BOOL)parseQRCode:(NSString*)data delegate:(id)delegate { diff --git a/Classes/BuschJaegerMainView.m b/Classes/BuschJaegerMainView.m index a464514a7..8ab5e15aa 100644 --- a/Classes/BuschJaegerMainView.m +++ b/Classes/BuschJaegerMainView.m @@ -125,6 +125,26 @@ static BuschJaegerMainView* mainViewInstance=nil; { [self displayIncomingCall:call]; } + case LinphoneCallOutgoingInit: + { + linphone_call_enable_camera(call, FALSE); + } + case LinphoneCallPausedByRemote: + case LinphoneCallConnected: + case LinphoneCallUpdated: + { + [navigationController popToViewController:welcomeView animated:FALSE]; + [navigationController pushViewController:callView animated:TRUE]; + break; + } + case LinphoneCallError: + case LinphoneCallEnd: + { + if ((linphone_core_get_calls([LinphoneManager getLc]) == NULL)) { + [navigationController popToViewController:welcomeView animated:TRUE]; + } + break; + } default: break; } @@ -144,26 +164,12 @@ static BuschJaegerMainView* mainViewInstance=nil; NSData *callData = [NSData dataWithBytes:&call length:sizeof(call)]; notif.userInfo = [NSDictionary dictionaryWithObject:callData forKey:@"call"]; - [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; + [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; } }else{ - NSError *setCategoryError = nil; - [[AVAudioSession sharedInstance] - setCategory: AVAudioSessionCategoryAmbient - error: &setCategoryError]; - //redirect audio to speaker - UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; - AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute - , sizeof (audioRouteOverride) - , &audioRouteOverride); - + [[LinphoneManager instance] enableSpeaker:TRUE]; AudioServicesPlaySystemSound([LinphoneManager instance].sounds.call); } - - [navigationController popToRootViewControllerAnimated:FALSE]; - [navigationController pushViewController:callView animated:TRUE]; - - linphone_call_enable_camera(call, FALSE); } + (BuschJaegerMainView *) instance { diff --git a/Classes/BuschJaegerSettingsView.m b/Classes/BuschJaegerSettingsView.m index 2c415eea2..77dbac9c2 100644 --- a/Classes/BuschJaegerSettingsView.m +++ b/Classes/BuschJaegerSettingsView.m @@ -65,8 +65,8 @@ [super viewDidLoad]; /* init gradients */ { - UIColor* col1 = [UIColor colorWithRed:32.0/255 green:45.0/255 blue:62.0/255 alpha:1.0]; - UIColor* col2 = [UIColor colorWithRed:18.0/255 green:26.0/255 blue:41.0/255 alpha:1.0]; + UIColor* col1 = BUSCHJAEGER_NORMAL_COLOR; + UIColor* col2 = BUSCHJAEGER_NORMAL_COLOR2; [BuschJaegerUtils createGradientForView:scanButton withTopColor:col1 bottomColor:col2]; [BuschJaegerUtils createGradientForView:backButton withTopColor:col1 bottomColor:col2]; @@ -109,6 +109,7 @@ [waitView setHidden:TRUE]; NSDictionary *dict = [NSDictionary dictionaryWithObject:[[LinphoneManager instance] configuration] forKey:@"configuration"]; [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneConfigurationUpdate object:self userInfo:dict]; + [[[LinphoneManager instance] configuration] saveFile:kLinphoneConfigurationPath]; } - (void)buschJaegerConfigParserError:(NSString *)error { @@ -122,6 +123,7 @@ [waitView setHidden:TRUE]; NSDictionary *dict = [NSDictionary dictionaryWithObject:[[LinphoneManager instance] configuration] forKey:@"configuration"]; [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneConfigurationUpdate object:self userInfo:dict]; + [[[LinphoneManager instance] configuration] saveFile:kLinphoneConfigurationPath]; } @end diff --git a/Classes/BuschJaegerStationViewController.m b/Classes/BuschJaegerStationViewController.m index 874ea4f2c..e4673484e 100644 --- a/Classes/BuschJaegerStationViewController.m +++ b/Classes/BuschJaegerStationViewController.m @@ -18,7 +18,10 @@ */ #import "BuschJaegerStationViewController.h" +#import "BuschJaegerUtils.h" +#import "UACellBackgroundView.h" #import "UIStationCell.h" +#import "LinphoneManager.h" @implementation BuschJaegerStationViewController @@ -34,6 +37,7 @@ [self.tableView reloadData]; } + #pragma mark - UITableViewDataSource Functions - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { @@ -49,6 +53,12 @@ UIStationCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; if (cell == nil) { cell = [[[UIStationCell alloc] initWithIdentifier:kCellId] autorelease]; + + // Background View + UACellBackgroundView *selectedBackgroundView = [[[UACellBackgroundView alloc] initWithFrame:CGRectZero] autorelease]; + cell.selectedBackgroundView = selectedBackgroundView; + [selectedBackgroundView setBackgroundColor:BUSCHJAEGER_NORMAL_COLOR]; + [selectedBackgroundView setBorderColor:[UIColor clearColor]]; } [cell setStation:[stations objectAtIndex:[indexPath row]]]; @@ -57,4 +67,14 @@ } +#pragma mark - UITableViewDelegate Functions + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [tableView deselectRowAtIndexPath:indexPath animated:NO]; + OutdoorStation *os = [stations objectAtIndex:[indexPath row]]; + NSString *addr = [FastAddressBook normalizeSipURI:[os address]]; + [[LinphoneManager instance] call:addr displayName:[os name] transfer:FALSE]; +} + + @end diff --git a/Classes/BuschJaegerUtils.h b/Classes/BuschJaegerUtils.h index 1a71519e5..e79b1c410 100644 --- a/Classes/BuschJaegerUtils.h +++ b/Classes/BuschJaegerUtils.h @@ -19,8 +19,19 @@ #import +#define BUSCHJAEGER_NORMAL_COLOR [UIColor colorWithRed:32.0/255 green:45.0/255 blue:62.0/255 alpha:1.0] +#define BUSCHJAEGER_NORMAL_COLOR2 [UIColor colorWithRed:18.0/255 green:26.0/255 blue:41.0/255 alpha:1.0] + +#define BUSCHJAEGER_RED_COLOR [UIColor colorWithRed:153.0/255 green:48.0/255 blue:48.0/255 alpha:1.0] +#define BUSCHJAEGER_RED_COLOR2 [UIColor colorWithRed:66.0/255 green:15.0/255 blue:15.0/255 alpha:1.0] + +#define BUSCHJAEGER_GREEN_COLOR [UIColor colorWithRed:91.0/255 green:161.0/255 blue:89.0/255 alpha:1.0] +#define BUSCHJAEGER_GREEN_COLOR2 [UIColor colorWithRed:25.0/255 green:54.0/255 blue:24.0/255 alpha:1.0] + + @interface BuschJaegerUtils : NSObject + (void)createGradientForView:(UIView*)view withTopColor:(UIColor*)topColor bottomColor:(UIColor*)bottomColor; ++ (void)createGradientForButton:(UIButton*)button withTopColor:(UIColor*)topColor bottomColor:(UIColor*)bottomColor; @end diff --git a/Classes/BuschJaegerUtils.m b/Classes/BuschJaegerUtils.m index 76148c438..8d80c75b6 100644 --- a/Classes/BuschJaegerUtils.m +++ b/Classes/BuschJaegerUtils.m @@ -31,4 +31,11 @@ [view.layer insertSublayer:gradient atIndex:0]; } ++ (void)createGradientForButton:(UIButton*)button withTopColor:(UIColor*)topColor bottomColor:(UIColor*)bottomColor { + CAGradientLayer* gradient = [CAGradientLayer layer]; + gradient.frame = button.bounds; + gradient.colors = [NSArray arrayWithObjects:(id)topColor.CGColor, (id)bottomColor.CGColor, nil]; + [button.layer insertSublayer:gradient below:button.imageView.layer]; +} + @end diff --git a/Classes/BuschJaegerWelcomeView.m b/Classes/BuschJaegerWelcomeView.m index 7442acf5b..901c6253d 100644 --- a/Classes/BuschJaegerWelcomeView.m +++ b/Classes/BuschJaegerWelcomeView.m @@ -74,7 +74,9 @@ } - (void)updateConfiguration:(BuschJaegerConfigParser *)configuration { - [tableController setStations:[NSArray arrayWithArray:[[configuration outdoorStations] allObjects]]]; + NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"ID" ascending:YES]; + NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; + [tableController setStations:[configuration.outdoorStations sortedArrayUsingDescriptors:sortDescriptors]]; } diff --git a/Classes/BuschJaegerWelcomeView.xib b/Classes/BuschJaegerWelcomeView.xib index 5551f1fdc..8ec91bda8 100644 --- a/Classes/BuschJaegerWelcomeView.xib +++ b/Classes/BuschJaegerWelcomeView.xib @@ -125,6 +125,7 @@ YES IBCocoaTouchFramework YES + 2 0 YES 100 diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index f55840e43..fd81c0e58 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -38,6 +38,7 @@ extern NSString *const kLinphoneRegistrationUpdate; extern NSString *const kLinphoneMainViewChange; /* MODIFICATION: Add buschjaeger configuration event */ extern NSString *const kLinphoneConfigurationUpdate; +extern NSString *const kLinphoneConfigurationPath; /**/ extern NSString *const kLinphoneAddressBookUpdate; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 2c848ff61..dcb31b2f4 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -42,6 +42,7 @@ NSString *const kLinphoneCallUpdate = @"LinphoneCallUpdate"; NSString *const kLinphoneRegistrationUpdate = @"LinphoneRegistrationUpdate"; /* MODIFICATION: Add buschjaeger configuration event */ NSString *const kLinphoneConfigurationUpdate = @"LinphoneConfigurationUpdate"; +NSString *const kLinphoneConfigurationPath = @"buschjaeger.ini"; /**/ NSString *const kLinphoneAddressBookUpdate = @"LinphoneAddressBookUpdate"; NSString *const kLinphoneMainViewChange = @"LinphoneMainViewChange"; @@ -204,6 +205,7 @@ struct codec_name_pref_table codec_pref_table[]={ /* MODIFICATION: Add buschjaeger configuration */ configuration = [[BuschJaegerConfigParser alloc] init]; + [configuration loadFile:kLinphoneConfigurationPath]; /**/ } return self; @@ -1187,5 +1189,6 @@ static LinphoneCoreVTable linphonec_vtable = { [[NSUserDefaults standardUserDefaults] setBool:true forKey:@"check_config_disable_preference"]; } } +/**/ @end diff --git a/Classes/Model/OutdoorStation.h b/Classes/Model/OutdoorStation.h index 1e8486888..c82e704eb 100644 --- a/Classes/Model/OutdoorStation.h +++ b/Classes/Model/OutdoorStation.h @@ -24,10 +24,15 @@ - (id)initWithId:(int)ID; +- (NSString*)write; ++ (id)parse:(NSString*)section array:(NSArray*)array; + @property (readonly) int ID; @property (copy) NSString* name; @property (copy) NSString* address; +@property (copy) NSString* type; @property (assign) BOOL screenshot; @property (assign) BOOL surveillance; + @end diff --git a/Classes/Model/OutdoorStation.m b/Classes/Model/OutdoorStation.m index 6f2bb8ec9..ced73553b 100644 --- a/Classes/Model/OutdoorStation.m +++ b/Classes/Model/OutdoorStation.m @@ -18,12 +18,15 @@ */ #import "OutdoorStation.h" +#import "BuschJaegerConfigParser.h" +#import "Utils.h" @implementation OutdoorStation @synthesize ID; @synthesize name; @synthesize address; +@synthesize type; @synthesize screenshot; @synthesize surveillance; @@ -41,4 +44,41 @@ [super dealloc]; } ++ (id)parse:(NSString*)section array:(NSArray*)array { + NSString *param; + OutdoorStation *os = nil; + if((param = [BuschJaegerConfigParser getRegexValue:@"^\\[outdoorstation_([\\d]+)\\]$" data:section]) != nil) { + os = [[OutdoorStation alloc] initWithId:[param intValue]]; + NSString *param; + for(NSString *entry in array) { + if((param = [BuschJaegerConfigParser getRegexValue:@"^address=(.*)$" data:entry]) != nil) { + os.address = param; + } else if((param = [BuschJaegerConfigParser getRegexValue:@"^name=(.*)$" data:entry]) != nil) { + os.name = param; + } else if((param = [BuschJaegerConfigParser getRegexValue:@"^type=(.*)$" data:entry]) != nil) { + os.type = param; + } else if((param = [BuschJaegerConfigParser getRegexValue:@"^screenshot=(.*)$" data:entry]) != nil) { + os.screenshot = [param compare:@"yes" options:NSCaseInsensitiveSearch] || [param compare:@"true" options:NSCaseInsensitiveSearch]; + } else if((param = [BuschJaegerConfigParser getRegexValue:@"^surveillance=(.*)$" data:entry]) != nil) { + os.surveillance = [param compare:@"yes" options:NSCaseInsensitiveSearch] || [param compare:@"true" options:NSCaseInsensitiveSearch]; + } else if([[entry stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] != 0){ + [LinphoneLogger log:LinphoneLoggerWarning format:@"Unknown entry in %@ section: %@", section, entry]; + } + } + } + + return os; +} + +- (NSString*)write { + NSMutableString *str = [NSMutableString string]; + [str appendString:[NSString stringWithFormat:@"\n[outdoorstation_%i]\n", ID]]; + [str appendString:[NSString stringWithFormat:@"address=%@\n", address]]; + [str appendString:[NSString stringWithFormat:@"name=%@\n", name]]; + [str appendString:[NSString stringWithFormat:@"type=%@\n", type]]; + [str appendString:[NSString stringWithFormat:@"screenshot=%@\n", screenshot?@"yes":@"no"]]; + [str appendString:[NSString stringWithFormat:@"surveillance=%@\n", surveillance?@"yes":@"no"]]; + return str; +} + @end