From daa81941b213bf47d6834e30c954e7b8f73f40e0 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 7 Feb 2012 11:41:46 +0100 Subject: [PATCH] Add support for sending DTMF without an active call --- Classes/BuschJaegerMainView.h | 2 ++ Classes/BuschJaegerMainView.m | 10 ++++++++++ Classes/LinphoneUI/UIDigitButton.h | 3 +++ Classes/LinphoneUI/UIDigitButton.m | 7 ++++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Classes/BuschJaegerMainView.h b/Classes/BuschJaegerMainView.h index ff95de81c..4477313a3 100644 --- a/Classes/BuschJaegerMainView.h +++ b/Classes/BuschJaegerMainView.h @@ -36,6 +36,8 @@ UIToggleButton* mute; UIDigitButton* lights; UIDigitButton* openDoor; + + LinphoneChatRoom * chatRoom; } @property (nonatomic, retain) IBOutlet UIView* videoView; diff --git a/Classes/BuschJaegerMainView.m b/Classes/BuschJaegerMainView.m index 91dba7a15..8baa0f9bf 100644 --- a/Classes/BuschJaegerMainView.m +++ b/Classes/BuschJaegerMainView.m @@ -106,6 +106,16 @@ [LinphoneManager set:videoView hidden:YES withName:"VIDEO_VIEW" andReason:__FUNCTION__]; linphone_core_set_native_video_window_id([LinphoneManager getLc],(unsigned long)videoView); + + if (!chatRoom) { + NSString* s = [NSString stringWithFormat:@"sip:100000001@%@", [[NSUserDefaults standardUserDefaults] stringForKey:@"adapter_ip_preference"]]; + const char* adapter = [s cStringUsingEncoding:[NSString defaultCStringEncoding]]; + chatRoom = linphone_core_create_chat_room([LinphoneManager getLc], adapter); + + lights->chatRoom = chatRoom; + openDoor->chatRoom = chatRoom; + } + } - (void) displayCall:(LinphoneCall *)call InProgressFromUI:(UIViewController *)viewCtrl forUser:(NSString *)username withDisplayName:(NSString *)displayName { diff --git a/Classes/LinphoneUI/UIDigitButton.h b/Classes/LinphoneUI/UIDigitButton.h index 70f7aee18..d18c94a7e 100644 --- a/Classes/LinphoneUI/UIDigitButton.h +++ b/Classes/LinphoneUI/UIDigitButton.h @@ -25,6 +25,9 @@ UITextField* mAddress; bool_t sendDtmfDuringCall; + +@public + LinphoneChatRoom* chatRoom; } -(void) initWithNumber:(char)digit ; diff --git a/Classes/LinphoneUI/UIDigitButton.m b/Classes/LinphoneUI/UIDigitButton.m index a800dd41d..e8926605e 100644 --- a/Classes/LinphoneUI/UIDigitButton.m +++ b/Classes/LinphoneUI/UIDigitButton.m @@ -28,7 +28,12 @@ -(void) touchDown:(id) sender { - linphone_core_send_dtmf([LinphoneManager getLc],mDigit); + if (linphone_core_get_current_call([LinphoneManager getLc])) { + linphone_core_send_dtmf([LinphoneManager getLc],mDigit); + } else if (chatRoom) { + char msg[] = {mDigit, '\0'}; + linphone_chat_room_send_message(chatRoom, msg); + } } -(void) touchUp:(id) sender {