diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 5f75c7652..ee31bfbf9 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -209,17 +209,17 @@ NSString *loc_key = [alert objectForKey:@"loc-key"]; /*if we receive a remote notification, it is because our TCP background socket was no more working. As a result, break it and refresh registers in order to make sure to receive incoming INVITE or MESSAGE*/ - LinphoneCore *lc=[LinphoneManager getLc]; - linphone_core_set_network_reachable(lc,FALSE); - linphone_core_set_network_reachable(lc,TRUE); + LinphoneCore *lc = [LinphoneManager getLc]; + linphone_core_set_network_reachable(lc, FALSE); + linphone_core_set_network_reachable(lc, TRUE); if(loc_key != nil) { if([loc_key isEqualToString:@"IM_MSG"]) { - [[LinphoneManager instance] addInhibitedEvent:kLinphoneTextReceivedSound]; + [[PhoneMainView instance] addInhibitedEvent:kLinphoneTextReceived]; [[PhoneMainView instance] changeCurrentView:[ChatViewController compositeViewDescription]]; - }else{ - //it's a call - [[LinphoneManager instance] didReceiveRemoteNotification]; - } + } else if([loc_key isEqualToString:@"IC_MSG"]) { + //it's a call + [[LinphoneManager instance] didReceiveRemoteNotification]; + } } } } diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index c63a76ca6..1ab4f74d1 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -33,7 +33,6 @@ extern NSString *const kLinphoneDisplayStatusUpdate; extern NSString *const kLinphoneTextReceived; -extern NSString *const kLinphoneTextReceivedSound; extern NSString *const kLinphoneCallUpdate; extern NSString *const kLinphoneRegistrationUpdate; extern NSString *const kLinphoneMainViewChange; @@ -79,7 +78,6 @@ typedef struct _LinphoneManagerSounds { time_t lastRemoteNotificationTime; Connectivity connectivity; BOOL stopWaitingRegisters; - NSMutableArray *inhibitedEvent; @public CallContext currentCallContextBeforeGoingBackground; @@ -111,9 +109,6 @@ typedef struct _LinphoneManagerSounds { - (void)refreshRegisters; -- (void)addInhibitedEvent:(NSString*)event; -- (BOOL)removeInhibitedEvent:(NSString*)event; - + (BOOL)copyFile:(NSString*)src destination:(NSString*)dst override:(BOOL)override; + (NSString*)bundleFile:(NSString*)file; + (NSString*)documentFile:(NSString*)file; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index c1be9d34e..ea7670878 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -40,7 +40,6 @@ static LinphoneManager* theLinphoneManager = nil; NSString *const kLinphoneDisplayStatusUpdate = @"LinphoneDisplayStatusUpdate"; NSString *const kLinphoneTextReceived = @"LinphoneTextReceived"; -NSString *const kLinphoneTextReceivedSound = @"LinphoneTextReceivedSound"; NSString *const kLinphoneCallUpdate = @"LinphoneCallUpdate"; NSString *const kLinphoneRegistrationUpdate = @"LinphoneRegistrationUpdate"; NSString *const kLinphoneAddressBookUpdate = @"LinphoneAddressBookUpdate"; @@ -204,13 +203,12 @@ struct codec_name_pref_table codec_pref_table[]={ } } - inhibitedEvent = [[NSMutableArray alloc] init]; logs = [[NSMutableArray alloc] init]; database = NULL; speakerEnabled = FALSE; [self openDatabase]; [self copyDefaultSettings]; - lastRemoteNotificationTime=0; + lastRemoteNotificationTime=0; } return self; } @@ -223,7 +221,6 @@ struct codec_name_pref_table codec_pref_table[]={ AudioServicesDisposeSystemSoundID(sounds.message); } - [inhibitedEvent release]; [fastAddressBook release]; [self closeDatabase]; [logs release]; @@ -713,7 +710,6 @@ static LinphoneCoreVTable linphonec_vtable = { } } - - (void)destroyLibLinphone { [mIterateTimer invalidate]; AVAudioSession *audioSession = [AVAudioSession sharedInstance]; @@ -732,16 +728,16 @@ static LinphoneCoreVTable linphonec_vtable = { } - (void)didReceiveRemoteNotification{ - lastRemoteNotificationTime=time(NULL); + lastRemoteNotificationTime=time(NULL); } - (BOOL)shouldAutoAcceptCall{ - if (lastRemoteNotificationTime!=0){ - if ((time(NULL)-lastRemoteNotificationTime)<15) - return TRUE; - lastRemoteNotificationTime=0; - } - return FALSE; + if (lastRemoteNotificationTime!=0){ + if ((time(NULL)-lastRemoteNotificationTime)<15) + return TRUE; + lastRemoteNotificationTime=0; + } + return FALSE; } - (BOOL)resignActive { @@ -1009,19 +1005,6 @@ static void audioRouteChangeListenerCallback ( } } -- (void)addInhibitedEvent:(NSString*)event { - [inhibitedEvent addObject:event]; -} - -- (BOOL)removeInhibitedEvent:(NSString*)event { - NSUInteger index = [inhibitedEvent indexOfObject:kLinphoneTextReceivedSound]; - if(index != NSNotFound) { - [inhibitedEvent removeObjectAtIndex:index]; - return TRUE; - } - return FALSE; -} - #pragma mark - Misc Functions diff --git a/Classes/LinphoneUI/UIStateBar.m b/Classes/LinphoneUI/UIStateBar.m index 25877646e..0ef68f27a 100644 --- a/Classes/LinphoneUI/UIStateBar.m +++ b/Classes/LinphoneUI/UIStateBar.m @@ -142,23 +142,17 @@ NSTimer *callSecurityTimer; message = NSLocalizedString(@"Registration failed", nil); break; case LinphoneRegistrationProgress: message = NSLocalizedString(@"Registration in progress", nil); break; - //case LinphoneRegistrationCleared: m= @"No SIP account"; break; default: break; } } registrationStateLabel.hidden = NO; switch(state) { - case LinphoneRegistrationCleared: - /* image.hidden = NO; - [image setImage:[UIImage imageNamed:@"status_orange.png"]]; - [spinner stopAnimating]; - [label setText:message != nil ? message : NSLocalizedString(@"No SIP account defined", nil)];*/ - break; case LinphoneRegistrationFailed: registrationStateImage.hidden = NO; image = [UIImage imageNamed:@"led_error.png"]; break; + case LinphoneRegistrationCleared: case LinphoneRegistrationNone: registrationStateImage.hidden = NO; image = [UIImage imageNamed:@"led_disconnected.png"]; diff --git a/Classes/PhoneMainView.h b/Classes/PhoneMainView.h index c3aee2c38..4d6c91ede 100644 --- a/Classes/PhoneMainView.h +++ b/Classes/PhoneMainView.h @@ -45,6 +45,7 @@ UIActionSheet *batteryActionSheet; int loadCount; NSMutableArray *viewStack; + NSMutableArray *inhibitedEvents; } @property (nonatomic, retain) IBOutlet UICompositeViewController *mainViewController; @@ -61,6 +62,9 @@ + (void)setOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated; +- (void)addInhibitedEvent:(id)event; +- (BOOL)removeInhibitedEvent:(id)event; + + (PhoneMainView*) instance; @end diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 95f08976c..9817aaa1c 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -43,6 +43,7 @@ static PhoneMainView* phoneMainViewInstance=nil; currentView = nil; viewStack = [[NSMutableArray alloc] init]; loadCount = 0; // For avoiding IOS 4 bug + inhibitedEvents = [[NSMutableArray alloc] init]; } - (id)init { @@ -73,7 +74,7 @@ static PhoneMainView* phoneMainViewInstance=nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; [mainViewController release]; - + [inhibitedEvents release]; [viewStack release]; [super dealloc]; @@ -566,6 +567,18 @@ static PhoneMainView* phoneMainViewInstance=nil; } } +- (void)addInhibitedEvent:(id)event { + [inhibitedEvents addObject:event]; +} + +- (BOOL)removeInhibitedEvent:(id)event { + NSUInteger index = [inhibitedEvents indexOfObject:event]; + if(index != NSNotFound) { + [inhibitedEvents removeObjectAtIndex:index]; + return TRUE; + } + return FALSE; +} #pragma mark - ActionSheet Functions @@ -595,7 +608,7 @@ static PhoneMainView* phoneMainViewInstance=nil; [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; } } else { - if(![[LinphoneManager instance] removeInhibitedEvent:kLinphoneTextReceivedSound]) { + if(![self removeInhibitedEvent:kLinphoneTextReceived]) { AudioServicesPlaySystemSound([LinphoneManager instance].sounds.message); } } @@ -634,7 +647,7 @@ static PhoneMainView* phoneMainViewInstance=nil; address = @"Unknown"; } if (![[LinphoneManager instance] shouldAutoAcceptCall]){ - // case where a remote notification is already received + // case where a remote notification is not already received // Create a new local notification appData->notification = [[UILocalNotification alloc] init]; if (appData->notification) { diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index 3994fb536..ee5d2ffeb 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -74,6 +74,9 @@ ret = [ret substringFromIndex:4]; } ret = [@"sip:" stringByAppendingString:ret]; + if([ret hasSuffix:@":5060"]) { + ret = [ret substringToIndex:[ret length] - 5]; + } } return ret; }