forked from mirrors/linphone-iphone
Fix call reference in local notifications
This commit is contained in:
parent
89dbfd3ef5
commit
da5488e866
3 changed files with 21 additions and 13 deletions
|
|
@ -211,14 +211,8 @@
|
|||
}
|
||||
|
||||
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
|
||||
if([notification.userInfo objectForKey:@"call"] != nil) {
|
||||
LinphoneCall* call;
|
||||
[(NSData*)[notification.userInfo objectForKey:@"call"] getBytes:&call];
|
||||
if (!call) {
|
||||
[LinphoneLogger logc:LinphoneLoggerWarning format:"Local notification received with nil call"];
|
||||
return;
|
||||
}
|
||||
linphone_core_accept_call([LinphoneManager getLc], call);
|
||||
if([notification.userInfo objectForKey:@"callId"] != nil) {
|
||||
[[LinphoneManager instance] acceptCallForCallId:[notification.userInfo objectForKey:@"callId"]];
|
||||
} else if([notification.userInfo objectForKey:@"chat"] != nil) {
|
||||
NSString *remoteContact = (NSString*)[notification.userInfo objectForKey:@"chat"];
|
||||
// Go to ChatRoom view
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ typedef struct _LinphoneManagerSounds {
|
|||
- (void)enableAutoAnswerForCallId:(NSString*) callid;
|
||||
- (void)addPushTokenToProxyConfig: (LinphoneProxyConfig*)cfg;
|
||||
- (BOOL)shouldAutoAcceptCallForCallId:(NSString*) callId;
|
||||
- (void)acceptCallForCallId:(NSString*)callid;
|
||||
- (void)waitForRegisterToArrive;
|
||||
|
||||
+ (void)kickOffNetworkConnection;
|
||||
|
|
|
|||
|
|
@ -427,9 +427,8 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char
|
|||
data->notification.alertBody =[NSString stringWithFormat:NSLocalizedString(@"IC_MSG",nil), address];
|
||||
data->notification.alertAction = NSLocalizedString(@"Answer", nil);
|
||||
data->notification.soundName = @"ring.caf";
|
||||
data->notification.userInfo = [NSDictionary dictionaryWithObject:[NSData dataWithBytes:&call length:sizeof(call)] forKey:@"call"];
|
||||
data->notification.userInfo = [NSDictionary dictionaryWithObject:callId forKey:@"callId"];
|
||||
|
||||
[[LinphoneManager instance] enableAutoAnswerForCallId:callId];
|
||||
[[UIApplication sharedApplication] presentLocalNotificationNow:data->notification];
|
||||
|
||||
if (!incallBgTask){
|
||||
|
|
@ -844,10 +843,24 @@ static LinphoneCoreVTable linphonec_vtable = {
|
|||
|
||||
}
|
||||
}
|
||||
static int comp_call_id (const LinphoneCall* call , const char *callid) {
|
||||
|
||||
static int comp_call_id(const LinphoneCall* call , const char *callid) {
|
||||
return strcmp(linphone_call_get_call_log(call)->call_id, callid);
|
||||
}
|
||||
- (void)enableAutoAnswerForCallId:(NSString*) callid{
|
||||
|
||||
- (void)acceptCallForCallId:(NSString*)callid {
|
||||
//first, make sure this callid is not already involved in a call
|
||||
if ([LinphoneManager isLcReady]) {
|
||||
MSList* calls = (MSList*)linphone_core_get_calls([LinphoneManager getLc]);
|
||||
MSList* call = ms_list_find_custom(calls, (MSCompareFunc)comp_call_id, [callid UTF8String]);
|
||||
if (call != NULL) {
|
||||
linphone_core_accept_call(theLinphoneCore, (LinphoneCall*)call->data);
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
- (void)enableAutoAnswerForCallId:(NSString*) callid {
|
||||
//first, make sure this callid is not already involved in a call
|
||||
if ([LinphoneManager isLcReady]) {
|
||||
MSList* calls = (MSList*)linphone_core_get_calls([LinphoneManager getLc]);
|
||||
|
|
@ -862,7 +875,7 @@ static int comp_call_id (const LinphoneCall* call , const char *callid) {
|
|||
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutoAcceptCallForCallId:(NSString*) callId{
|
||||
- (BOOL)shouldAutoAcceptCallForCallId:(NSString*) callId {
|
||||
for (NSString* pendingNotif in pendindCallIdFromRemoteNotif) {
|
||||
if ([pendingNotif compare:callId] == NSOrderedSame) {
|
||||
[pendindCallIdFromRemoteNotif removeObject:pendingNotif];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue