Small fixes

This commit is contained in:
Yann Diorcet 2012-09-12 17:36:09 +02:00
parent 3d3e7257da
commit 5e97c0c7e7
7 changed files with 40 additions and 48 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -74,6 +74,9 @@
ret = [ret substringFromIndex:4];
}
ret = [@"sip:" stringByAppendingString:ret];
if([ret hasSuffix:@":5060"]) {
ret = [ret substringToIndex:[ret length] - 5];
}
}
return ret;
}