diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 6dcb8fe49..9de0d3acd 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -71,6 +71,7 @@ typedef struct _LinphoneCallAppData { id settingsStore; sqlite3 *database; + NSDictionary *castelCommands; @public CallContext currentCallContextBeforeGoingBackground; @@ -105,6 +106,7 @@ typedef struct _LinphoneCallAppData { @property (readonly) const char* frontCamId; @property (readonly) const char* backCamId; @property (readonly) sqlite3* database; +@property (readonly) NSDictionary* castelCommands; @end diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 4eb34c7fc..d9f2083e3 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -31,6 +31,9 @@ #import "LinphoneCoreSettingsStore.h" #import "ChatModel.h" +#import "GDataXMLNode.h" +#import "OrderedDictionary.h" + #include "linphonecore_utils.h" #include "lpconfig.h" #include "private.h" @@ -67,6 +70,7 @@ extern void libmsbcg729_init(); @synthesize settingsStore; @synthesize database; @synthesize fastAddressBook; +@synthesize castelCommands; struct codec_name_pref_table{ const char *name; @@ -164,6 +168,7 @@ struct codec_name_pref_table codec_pref_table[]={ [fastAddressBook release]; [self closeDatabase]; [settingsStore release]; + [castelCommands release]; [super dealloc]; } @@ -333,6 +338,37 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo - (void)onTextReceived:(LinphoneCore *)lc room:(LinphoneChatRoom *)room from:(const LinphoneAddress *)from message:(const char *)message { + if(message != NULL) { + NSError *error; + GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithXMLString:[NSString stringWithUTF8String:message] options:0 error:&error]; + if (doc == nil) { + [LinphoneLogger log:LinphoneLoggerError format:@"Can't parse XML: %@", [error localizedDescription]]; + return; + } + NSArray *commands = [doc nodesForXPath:@"//VDUCMediaConfig/MediaConfig/CommandCode" error:nil]; + if(castelCommands != nil) { + [castelCommands release]; + castelCommands = nil; + } + if(commands != nil && [commands count]) { + OrderedDictionary *tempDict = [OrderedDictionary dictionaryWithCapacity:[commands count]]; + castelCommands = tempDict; + for(GDataXMLElement *element in commands) { + GDataXMLNode *code = [element attributeForName:@"Code"]; + if(code != nil) { + NSArray *labelArray = [element elementsForName:@"Label"]; + if(labelArray != nil && [labelArray count] == 1) { + GDataXMLNode *label = [labelArray objectAtIndex:0]; + [tempDict setObject:[code stringValue] forKey:[label stringValue]]; + } + } + } + [[NSNotificationCenter defaultCenter] postNotificationName:@"LinphoneCastelCommands" object:self userInfo:castelCommands]; + } + } + + /* + MODIFICATION: Remove Chat char *fromStr = linphone_address_as_string_uri_only(from); if(fromStr == NULL) return; @@ -358,6 +394,7 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo nil] autorelease]; [[NSNotificationCenter defaultCenter] postNotificationName:@"LinphoneTextReceived" object:self userInfo:dict]; [chat release]; + */ } static void linphone_iphone_text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) { diff --git a/Classes/LinphoneUI/UICallBar.m b/Classes/LinphoneUI/UICallBar.m index 4ecc77cb2..c882efe90 100644 --- a/Classes/LinphoneUI/UICallBar.m +++ b/Classes/LinphoneUI/UICallBar.m @@ -229,10 +229,17 @@ selector:@selector(callUpdateEvent:) name:@"LinphoneCallUpdate" object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(castelCommandsEvent:) + name:@"LinphoneCastelCommands" + object:nil]; // Update on show LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]); LinphoneCallState state = (call != NULL)?linphone_call_get_state(call): 0; [self callUpdate:call state:state]; + + [self castelCommandsUpdate:[[LinphoneManager instance] castelCommands]]; } - (void)viewWillDisappear:(BOOL)animated { @@ -241,8 +248,12 @@ [[NSNotificationCenter defaultCenter] removeObserver:self name:@"LinphoneCallUpdate" object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self + name:@"LinphoneCastelCommands" + object:nil]; } + #pragma mark - Event Functions - (void)callUpdateEvent:(NSNotification*)notif { @@ -251,8 +262,36 @@ [self callUpdate:call state:state]; } +- (void)castelCommandsEvent:(NSNotification*)notif { + [self castelCommandsUpdate:[notif userInfo]]; +} -#pragma mark - + +#pragma mark - + +- (void)castelCommandsUpdate:(NSDictionary*)castelCommands { + [option1Button setHidden:TRUE]; + [option2Button setHidden:TRUE]; + [option3Button setHidden:TRUE]; + if(castelCommands != nil) { + NSArray *array = [castelCommands allKeys]; + if([array count] >= 1) { + NSString *label = [array objectAtIndex:0]; + [option1Button setHidden:FALSE]; + [option1Button setTitle:label forState:UIControlStateNormal]; + } + if([array count] >= 2) { + NSString *label = [array objectAtIndex:1]; + [option2Button setHidden:FALSE]; + [option2Button setTitle:label forState:UIControlStateNormal]; + } + if([array count] >= 3) { + NSString *label = [array objectAtIndex:2]; + [option3Button setHidden:FALSE]; + [option3Button setTitle:label forState:UIControlStateNormal]; + } + } +} - (void)callUpdate:(LinphoneCall*)call state:(LinphoneCallState)state { if(![LinphoneManager isLcReady]) { diff --git a/Classes/LinphoneUI/UICallBar.xib b/Classes/LinphoneUI/UICallBar.xib index 921672f86..f782dbed8 100644 --- a/Classes/LinphoneUI/UICallBar.xib +++ b/Classes/LinphoneUI/UICallBar.xib @@ -3,19 +3,19 @@ 1296 11E53 - 2182 + 2549 1138.47 569.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 1181 + 1498 - IBUIButton - IBUIActivityIndicatorView - IBUIView - IBUIImageView IBProxyObject + IBUIActivityIndicatorView + IBUIButton + IBUIImageView + IBUIView com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -43,7 +43,6 @@ {{0, 335}, {320, 125}} - _NS:9 1 @@ -803,7 +802,6 @@ {{0, 248}, {480, 72}} - _NS:9 1 @@ -1237,7 +1235,6 @@ {{285, 0}, {65, 82}} - _NS:9 NO 22 @@ -1403,7 +1400,6 @@ {{415, 0}, {65, 82}} - _NS:9 NO 27 @@ -1634,14 +1630,6 @@ 138 - - - dialerButton - - - - 139 - optionsAddButton @@ -1658,14 +1646,6 @@ 149 - - - option2Button - - - - 140 - option3Button @@ -1674,6 +1654,22 @@ 151 + + + dialerButton + + + + 152 + + + + option2Button + + + + 153 + onPadClick: @@ -2305,7 +2301,7 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin UIToggleButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin - + UIDigitButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -2359,7 +2355,7 @@ - 151 + 153 @@ -2759,6 +2755,6 @@ {160, 134} {130, 163} - 1181 + 1498 diff --git a/Classes/LinphoneUI/UIMainBar.m b/Classes/LinphoneUI/UIMainBar.m index ce79586f6..03d5c9bdc 100644 --- a/Classes/LinphoneUI/UIMainBar.m +++ b/Classes/LinphoneUI/UIMainBar.m @@ -76,10 +76,12 @@ selector:@selector(callUpdate:) name:@"LinphoneCallUpdate" object:nil]; + /* MODIFICATION Remove chat [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textReceived:) name:@"LinphoneTextReceived" object:nil]; + */ [self update]; } @@ -92,9 +94,11 @@ [[NSNotificationCenter defaultCenter] removeObserver:self name:@"LinphoneCallUpdate" object:nil]; + /* MODIFICATION Remove chat [[NSNotificationCenter defaultCenter] removeObserver:self name:@"LinphoneTextReceived" object:nil]; + */ } - (void)viewDidLoad { @@ -137,10 +141,11 @@ [self updateView:[[PhoneMainView instance] firstView]]; } +/* MODIFICATION Remove chat - (void)textReceived:(NSNotification*)notif { [self updateUnreadMessage:[ChatModel unreadMessages]]; } - + */ #pragma mark - @@ -151,10 +156,13 @@ } else { [self updateMissedCall:0]; } + /* MODIFICATION Remove chat [self updateUnreadMessage:[ChatModel unreadMessages]]; + */ } - (void)updateUnreadMessage:(int)unreadMessage{ + /* MODIFICATION Remove chat if (unreadMessage > 0) { if([chatNotificationView isHidden]) { [chatNotificationView setHidden:FALSE]; @@ -171,6 +179,7 @@ }]; } } + */ } - (void)updateMissedCall:(int)missedCall{ diff --git a/castel.xsd b/castel.xsd new file mode 100644 index 000000000..db15656c8 --- /dev/null +++ b/castel.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 8ebbb3686..088ccedab 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -198,8 +198,6 @@ D32B6E2415A5B2020033019F /* chat_send_disabled.png in Resources */ = {isa = PBXBuildFile; fileRef = D32B6E2315A5B2020033019F /* chat_send_disabled.png */; }; D32B6E2C15A5C0800033019F /* database.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = D32B6E2B15A5C0800033019F /* database.sqlite */; }; D32B6E2F15A5C0AC0033019F /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D32B6E2E15A5C0AC0033019F /* libsqlite3.dylib */; }; - D32B6E3815A5C2430033019F /* ChatModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D32B6E3715A5C2430033019F /* ChatModel.m */; }; - D32B6E3915A5C2430033019F /* ChatModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D32B6E3715A5C2430033019F /* ChatModel.m */; }; D32B9DFC15A2F131000B6DEC /* FastAddressBook.m in Sources */ = {isa = PBXBuildFile; fileRef = D32B9DFB15A2F131000B6DEC /* FastAddressBook.m */; }; D32B9DFD15A2F131000B6DEC /* FastAddressBook.m in Sources */ = {isa = PBXBuildFile; fileRef = D32B9DFB15A2F131000B6DEC /* FastAddressBook.m */; }; D32D5AA715ADE5D9008593F3 /* button_alert_background_default.png in Resources */ = {isa = PBXBuildFile; fileRef = D32D5AA515ADE5D9008593F3 /* button_alert_background_default.png */; }; @@ -1399,6 +1397,7 @@ D3A8BB7815A6CC3200F96BE5 /* setup_back_disabled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = setup_back_disabled.png; path = Resources/setup_back_disabled.png; sourceTree = ""; }; D3A8BB7915A6CC3200F96BE5 /* setup_cancel_disabled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = setup_cancel_disabled.png; path = Resources/setup_cancel_disabled.png; sourceTree = ""; }; D3A8BB7A15A6CC3200F96BE5 /* setup_start_disabled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = setup_start_disabled.png; path = Resources/setup_start_disabled.png; sourceTree = ""; }; + D3B829FC15C148C90036C93E /* castel.xsd */ = {isa = PBXFileReference; lastKnownFileType = text; path = castel.xsd; sourceTree = ""; }; D3B9A3DA15A58C440096EA4E /* chat_field.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = chat_field.png; path = Resources/chat_field.png; sourceTree = ""; }; D3B9A3DB15A58C440096EA4E /* chat_ok_default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = chat_ok_default.png; path = Resources/chat_ok_default.png; sourceTree = ""; }; D3B9A3DC15A58C440096EA4E /* chat_ok_over.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = chat_ok_over.png; path = Resources/chat_ok_over.png; sourceTree = ""; }; @@ -2141,6 +2140,7 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( + D3B829FC15C148C90036C93E /* castel.xsd */, 2258633C11410BAC00C5A737 /* README */, 22276E8013C73D3100210156 /* libavcodec.a */, 22276E8113C73D3100210156 /* libavutil.a */, @@ -3416,7 +3416,6 @@ D32B9DFC15A2F131000B6DEC /* FastAddressBook.m in Sources */, D3196D3E15A32BD8007FEEBA /* UITransferButton.m in Sources */, D350F20E15A43BB100149E54 /* WizardViewController.m in Sources */, - D32B6E3815A5C2430033019F /* ChatModel.m in Sources */, D389362615A6D19800A3A3AA /* CPAnimationSequence.m in Sources */, D389362815A6D19800A3A3AA /* CPAnimationStep.m in Sources */, D3128FE115AABC7E00A2147A /* ContactDetailsViewController.m in Sources */, @@ -3500,7 +3499,6 @@ D32B9DFD15A2F131000B6DEC /* FastAddressBook.m in Sources */, D3196D3F15A32BD8007FEEBA /* UITransferButton.m in Sources */, D350F20F15A43BB100149E54 /* WizardViewController.m in Sources */, - D32B6E3915A5C2430033019F /* ChatModel.m in Sources */, D389362715A6D19800A3A3AA /* CPAnimationSequence.m in Sources */, D389362915A6D19800A3A3AA /* CPAnimationStep.m in Sources */, D3128FE215AABC7E00A2147A /* ContactDetailsViewController.m in Sources */,