Improve BJ Application

This commit is contained in:
Yann Diorcet 2012-08-20 18:00:13 +02:00
parent d890a74036
commit 537f213a8c
16 changed files with 314 additions and 204 deletions

View file

@ -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;

View file

@ -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];
}

View file

@ -162,11 +162,11 @@
<reference key="IBUINormalTitleShadowColor" ref="628689408"/>
<object class="NSCustomResource" key="IBUISelectedImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">bj_mute_on.png</string>
<string key="NSResourceName">bj_mute_off.png</string>
</object>
<object class="NSCustomResource" key="IBUINormalImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">bj_mute_off.png</string>
<string key="NSResourceName">bj_mute_on.png</string>
</object>
<reference key="IBUIFontDescription" ref="488695651"/>
<reference key="IBUIFont" ref="1052967191"/>
@ -177,7 +177,6 @@
<string key="NSFrame">{{207, 0}, {73, 58}}</string>
<reference key="NSSuperview" ref="903884486"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:225</string>
<reference key="IBUIBackgroundColor" ref="666829842"/>
<bool key="IBUIOpaque">NO</bool>
@ -281,54 +280,6 @@
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">startCall</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="427701461"/>
</object>
<int key="connectionID">66</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">takeCall</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="910162139"/>
</object>
<int key="connectionID">69</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">endOrRejectCall</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="842436331"/>
</object>
<int key="connectionID">70</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">mute</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="889522260"/>
</object>
<int key="connectionID">71</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">openDoor</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="1031602630"/>
</object>
<int key="connectionID">72</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">lights</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="762727327"/>
</object>
<int key="connectionID">73</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">videoView</string>
@ -347,11 +298,59 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">decline</string>
<string key="label">declineButton</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="33985418"/>
</object>
<int key="connectionID">76</int>
<int key="connectionID">77</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">endOrRejectCallButton</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="842436331"/>
</object>
<int key="connectionID">78</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">lightsButton</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="762727327"/>
</object>
<int key="connectionID">79</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">openDoorButton</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="1031602630"/>
</object>
<int key="connectionID">80</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">startCallButton</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="427701461"/>
</object>
<int key="connectionID">82</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">takeCallButton</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="910162139"/>
</object>
<int key="connectionID">83</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">microButton</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="889522260"/>
</object>
<int key="connectionID">84</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
@ -424,43 +423,43 @@
<int key="objectID">8</int>
<reference key="object" ref="1031602630"/>
<reference key="parent" ref="903884486"/>
<string key="objectName">OpenDoor</string>
<string key="objectName">Open Door Button</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">10</int>
<reference key="object" ref="762727327"/>
<reference key="parent" ref="903884486"/>
<string key="objectName">Light</string>
<string key="objectName">Light Button</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">9</int>
<reference key="object" ref="889522260"/>
<reference key="parent" ref="903884486"/>
<string key="objectName">Mute</string>
<string key="objectName">Micro Button</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">43</int>
<reference key="object" ref="33985418"/>
<reference key="parent" ref="903884486"/>
<string key="objectName">Decline call</string>
<string key="objectName">Decline Call Button</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">6</int>
<reference key="object" ref="427701461"/>
<reference key="parent" ref="903884486"/>
<string key="objectName">StartCall</string>
<string key="objectName">Start Call Button</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">57</int>
<reference key="object" ref="910162139"/>
<reference key="parent" ref="903884486"/>
<string key="objectName">AcceptCall</string>
<string key="objectName">Accept Call Button</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">7</int>
<reference key="object" ref="842436331"/>
<reference key="parent" ref="903884486"/>
<string key="objectName">StopCall</string>
<string key="objectName">Stop Call Button</string>
</object>
</array>
</object>
@ -493,16 +492,16 @@
<string key="8.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<real value="0.0" key="8.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
<string key="8.object.labelIdentifier">IBBuiltInLabel-Red</string>
<string key="9.CustomClassName">UIMuteButton</string>
<string key="9.CustomClassName">UIMicroButton</string>
<string key="9.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<real value="2" key="9.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
<real value="0.0" key="9.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
<string key="9.object.labelIdentifier">IBBuiltInLabel-Red</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">76</int>
<int key="maxID">84</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -524,42 +523,42 @@
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="decline">UIHangUpButton</string>
<string key="endOrRejectCall">UIHangUpButton</string>
<string key="lights">UIDigitButton</string>
<string key="mute">UIToggleButton</string>
<string key="openDoor">UIDigitButton</string>
<string key="startCall">UIButton</string>
<string key="takeCall">UIButton</string>
<string key="declineButton">UIHangUpButton</string>
<string key="endOrRejectCallButton">UIHangUpButton</string>
<string key="lightsButton">UIDigitButton</string>
<string key="openDoorButton">UIDigitButton</string>
<string key="speakerButton">UIToggleButton</string>
<string key="startCallButton">UIButton</string>
<string key="takeCallButton">UIButton</string>
<string key="videoView">UIView</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="decline">
<string key="name">decline</string>
<object class="IBToOneOutletInfo" key="declineButton">
<string key="name">declineButton</string>
<string key="candidateClassName">UIHangUpButton</string>
</object>
<object class="IBToOneOutletInfo" key="endOrRejectCall">
<string key="name">endOrRejectCall</string>
<object class="IBToOneOutletInfo" key="endOrRejectCallButton">
<string key="name">endOrRejectCallButton</string>
<string key="candidateClassName">UIHangUpButton</string>
</object>
<object class="IBToOneOutletInfo" key="lights">
<string key="name">lights</string>
<object class="IBToOneOutletInfo" key="lightsButton">
<string key="name">lightsButton</string>
<string key="candidateClassName">UIDigitButton</string>
</object>
<object class="IBToOneOutletInfo" key="mute">
<string key="name">mute</string>
<object class="IBToOneOutletInfo" key="openDoorButton">
<string key="name">openDoorButton</string>
<string key="candidateClassName">UIDigitButton</string>
</object>
<object class="IBToOneOutletInfo" key="speakerButton">
<string key="name">speakerButton</string>
<string key="candidateClassName">UIToggleButton</string>
</object>
<object class="IBToOneOutletInfo" key="openDoor">
<string key="name">openDoor</string>
<string key="candidateClassName">UIDigitButton</string>
</object>
<object class="IBToOneOutletInfo" key="startCall">
<string key="name">startCall</string>
<object class="IBToOneOutletInfo" key="startCallButton">
<string key="name">startCallButton</string>
<string key="candidateClassName">UIButton</string>
</object>
<object class="IBToOneOutletInfo" key="takeCall">
<string key="name">takeCall</string>
<object class="IBToOneOutletInfo" key="takeCallButton">
<string key="name">takeCallButton</string>
<string key="candidateClassName">UIButton</string>
</object>
<object class="IBToOneOutletInfo" key="videoView">
@ -607,6 +606,14 @@
<string key="minorKey">./Classes/UILongTouchButton.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIMicroButton</string>
<string key="superclassName">UIToggleButton</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/UIMicroButton.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIToggleButton</string>
<string key="superclassName">UIButton</string>

View file

@ -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<BuschJaegerConfigParser>)delegate;
+ (NSString*)getRegexValue:(NSString*)regexString data:(NSString*)data;
@end

View file

@ -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<BuschJaegerConfigParser>)delegate {
- (BOOL)parseConfig:(NSString*)data delegate:(id<BuschJaegerConfigParser>)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<BuschJaegerConfigParser>)delegate {

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -19,8 +19,19 @@
#import <Foundation/Foundation.h>
#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

View file

@ -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

View file

@ -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]];
}

View file

@ -125,6 +125,7 @@
<bool key="IBUIClipsSubviews">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIAlwaysBounceVertical">YES</bool>
<int key="IBUIIndicatorStyle">2</int>
<int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
<float key="IBUIRowHeight">100</float>

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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