From 6d657edc692aacefb85d8d12e8ae7c8bbe7f49c6 Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Mon, 14 Jan 2013 10:37:56 +0100 Subject: [PATCH] Fix zrtp feature --- Classes/LinphoneCoreSettingsStore.m | 4 +- Classes/LinphoneUI/UIStateBar.h | 5 + Classes/LinphoneUI/UIStateBar.m | 52 ++++- Classes/LinphoneUI/UIStateBar.xib | 200 +++++++++++++++++- Classes/SettingsViewController.m | 34 ++- Resources/en.lproj/Localizable.strings | Bin 18562 -> 19034 bytes Resources/fr.lproj/Localizable.strings | Bin 19158 -> 19680 bytes linphone.ldb/Contents.plist | 57 ++++- .../Localizable/1/Localizable.strings | Bin 18562 -> 19034 bytes 9 files changed, 330 insertions(+), 22 deletions(-) diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 65918750f..6cff4b33e 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -431,7 +431,6 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); NSArray* matches = [regex matchesInString:text options:0 range:NSMakeRange(0, [text length])]; if([matches count] == 1) { NSTextCheckingResult *match = [matches objectAtIndex:0]; - NSLog(@"%d", [match numberOfRanges]); bool range = [match rangeAtIndex:2].length > 0; if(!range) { NSRange rangeMinPort = [match rangeAtIndex:1]; @@ -503,7 +502,8 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionSRTP); else if (menc && [menc compare:@"ZRTP"] == NSOrderedSame) linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionZRTP); - else linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionNone); + else + linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionNone); NSString* stun_server = [self stringForKey:@"stun_preference"]; if ([stun_server length] > 0){ diff --git a/Classes/LinphoneUI/UIStateBar.h b/Classes/LinphoneUI/UIStateBar.h index a2f075a19..c9f80b725 100644 --- a/Classes/LinphoneUI/UIStateBar.h +++ b/Classes/LinphoneUI/UIStateBar.h @@ -19,13 +19,18 @@ #import #import "TPMultiLayoutViewController.h" +#import "DTActionSheet.h" @interface UIStateBar : TPMultiLayoutViewController { + DTActionSheet *securitySheet; } @property (nonatomic, retain) IBOutlet UIImageView* registrationStateImage; @property (nonatomic, retain) IBOutlet UILabel* registrationStateLabel; @property (nonatomic, retain) IBOutlet UIImageView* callQualityImage; @property (nonatomic, retain) IBOutlet UIImageView* callSecurityImage; +@property (nonatomic, retain) IBOutlet UIButton* callSecurityButton; + +- (IBAction)doSecurityClick:(id)sender; @end diff --git a/Classes/LinphoneUI/UIStateBar.m b/Classes/LinphoneUI/UIStateBar.m index 926d3b397..fcc7068b3 100644 --- a/Classes/LinphoneUI/UIStateBar.m +++ b/Classes/LinphoneUI/UIStateBar.m @@ -19,8 +19,7 @@ #import "UIStateBar.h" #import "LinphoneManager.h" - -#include "linphonecore.h" +#import "PhoneMainView.h" @implementation UIStateBar @@ -28,6 +27,7 @@ @synthesize registrationStateLabel; @synthesize callQualityImage; @synthesize callSecurityImage; +@synthesize callSecurityButton; NSTimer *callQualityTimer; NSTimer *callSecurityTimer; @@ -40,11 +40,20 @@ NSTimer *callSecurityTimer; if(self != nil) { self->callSecurityImage = nil; self->callQualityImage = nil; + self->securitySheet = nil; } return self; } - (void) dealloc { + if(securitySheet) { + [securitySheet release]; + } + [registrationStateImage release]; + [registrationStateLabel release]; + [callQualityImage release]; + [callSecurityImage release]; + [callSecurityButton release]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [callQualityTimer invalidate]; [callQualityTimer release]; @@ -183,6 +192,9 @@ NSTimer *callSecurityTimer; } const MSList *list = linphone_core_get_calls([LinphoneManager getLc]); if(list == NULL) { + if(securitySheet) { + [securitySheet dismissWithClickedButtonIndex:securitySheet.destructiveButtonIndex animated:TRUE]; + } [callSecurityImage setHidden:true]; return; } @@ -238,6 +250,42 @@ NSTimer *callSecurityTimer; } +#pragma mark - Action Functions + +- (IBAction)doSecurityClick:(id)sender { + if([LinphoneManager isLcReady] && linphone_core_get_calls_nb([LinphoneManager getLc])) { + LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]); + if(call != NULL) { + LinphoneMediaEncryption enc = linphone_call_params_get_media_encryption(linphone_call_get_current_params(call)); + if(enc == LinphoneMediaEncryptionZRTP) { + bool valid = linphone_call_get_authentication_token_verified(call); + NSString *message = nil; + if(valid) { + message = NSLocalizedString(@"Remove trust in the peer?",nil); + } else { + message = [NSString stringWithFormat:NSLocalizedString(@"Confirm the following SAS with the peer:\n%s",nil), + linphone_call_get_authentication_token(call)]; + } + if(securitySheet == nil) { + securitySheet = [[DTActionSheet alloc] initWithTitle:message]; + [securitySheet addButtonWithTitle:NSLocalizedString(@"Ok",nil) block:^(){ + linphone_call_set_authentication_token_verified(call, !valid); + [securitySheet release]; + securitySheet = nil; + }]; + + [securitySheet addDestructiveButtonWithTitle:NSLocalizedString(@"Cancel",nil) block:^(){ + [securitySheet release]; + securitySheet = nil; + }]; + [securitySheet showInView:[PhoneMainView instance].view]; + } + } + } + } +} + + #pragma mark - TPMultiLayoutViewController Functions - (NSDictionary*)attributesForView:(UIView*)view { diff --git a/Classes/LinphoneUI/UIStateBar.xib b/Classes/LinphoneUI/UIStateBar.xib index 688a607a1..180f20a12 100644 --- a/Classes/LinphoneUI/UIStateBar.xib +++ b/Classes/LinphoneUI/UIStateBar.xib @@ -2,9 +2,9 @@ 1536 - 11E53 + 11G63 2840 - 1138.47 + 1138.51 569.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -12,6 +12,7 @@ IBProxyObject + IBUIButton IBUIImageView IBUILabel IBUIView @@ -41,6 +42,7 @@ 274 {320, 23} + _NS:9 1 @@ -56,6 +58,7 @@ 292 {{6, 6}, {10, 10}} + _NS:567 2 @@ -75,6 +78,7 @@ 290 {{22, 0}, {222, 20}} + _NS:328 NO @@ -109,7 +113,8 @@ 289 {{252, 3}, {27, 17}} - + + _NS:567 4 NO @@ -123,6 +128,8 @@ 289 {{287, 3}, {27, 17}} + + _NS:567 1 5 @@ -132,9 +139,50 @@ IBCocoaTouchFramework + + + 289 + {{284, 0}, {33, 23}} + + + + _NS:9 + NO + 6 + + + + IBCocoaTouchFramework + 0 + 0 + NO + NO + + 3 + MQA + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + 2 + 15 + + + Helvetica-Bold + 15 + 16 + + {320, 23} + _NS:196 @@ -152,6 +200,7 @@ 274 {480, 23} + _NS:9 1 @@ -164,6 +213,7 @@ 292 {{6, 6}, {10, 10}} + _NS:567 2 @@ -176,6 +226,7 @@ 290 {{22, 0}, {382, 20}} + _NS:328 NO @@ -197,6 +248,7 @@ 289 {{412, 3}, {27, 17}} + _NS:567 4 @@ -208,15 +260,45 @@ 289 {{447, 3}, {27, 17}} + + _NS:567 1 5 NO IBCocoaTouchFramework + + + 289 + {{444, 0}, {33, 23}} + + + + _NS:9 + NO + 6 + + + + IBCocoaTouchFramework + 0 + 0 + NO + NO + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + + {480, 23} + _NS:196 @@ -281,6 +363,23 @@ 26 + + + callSecurityButton + + + + 29 + + + + doSecurityClick: + + + 7 + + 30 + @@ -310,6 +409,7 @@ + Portrait View @@ -353,6 +453,7 @@ + Landscape View @@ -387,6 +488,18 @@ registrationStateImage + + 27 + + + callSecurityButton + + + 28 + + + callSecurityButton + @@ -403,6 +516,10 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -411,9 +528,82 @@ - 26 + 30 + + + + + TPMultiLayoutViewController + UIViewController + + UIView + UIView + + + + landscapeView + UIView + + + portraitView + UIView + + + + IBProjectSource + ./Classes/TPMultiLayoutViewController.h + + + + UIStateBar + TPMultiLayoutViewController + + doSecurityClick: + id + + + doSecurityClick: + + doSecurityClick: + id + + + + UIImageView + UIButton + UIImageView + UIImageView + UILabel + + + + callQualityImage + UIImageView + + + callSecurityButton + UIButton + + + callSecurityImage + UIImageView + + + registrationStateImage + UIImageView + + + registrationStateLabel + UILabel + + + + IBProjectSource + ./Classes/UIStateBar.h + + + - 0 IBCocoaTouchFramework YES diff --git a/Classes/SettingsViewController.m b/Classes/SettingsViewController.m index 0fcd374f2..8cb63f9c8 100644 --- a/Classes/SettingsViewController.m +++ b/Classes/SettingsViewController.m @@ -546,17 +546,29 @@ static UICompositeViewDescription *compositeDescription = nil; [values removeObject:@"tls"]; [dict setObject:values forKey:@"Values"]; return [[[IASKSpecifier alloc] initWithSpecifier:dict] autorelease]; - } else if ([[specifier key] isEqualToString:@"media_encryption_preference"]) { - NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[specifier specifierDict]]; - NSMutableArray *titles = [NSMutableArray arrayWithArray:[dict objectForKey:@"Titles"]]; - [titles removeObject:@"ZRTP"]; - [titles removeObject:@"SRTP"]; - [dict setObject:titles forKey:@"Titles"]; - NSMutableArray *values = [NSMutableArray arrayWithArray:[dict objectForKey:@"Values"]]; - [values removeObject:@"ZRTP"]; - [values removeObject:@"SRTP"]; - [dict setObject:values forKey:@"Values"]; - return [[[IASKSpecifier alloc] initWithSpecifier:dict] autorelease]; + } +#else + if([LinphoneManager isLcReady]) { + if ([[specifier key] isEqualToString:@"media_encryption_preference"]) { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[specifier specifierDict]]; + if(!linphone_core_media_encryption_supported([LinphoneManager getLc], LinphoneMediaEncryptionZRTP)) { + NSMutableArray *titles = [NSMutableArray arrayWithArray:[dict objectForKey:@"Titles"]]; + [titles removeObject:@"ZRTP"]; + [dict setObject:titles forKey:@"Titles"]; + NSMutableArray *values = [NSMutableArray arrayWithArray:[dict objectForKey:@"Values"]]; + [values removeObject:@"ZRTP"]; + [dict setObject:values forKey:@"Values"]; + } + if(!linphone_core_media_encryption_supported([LinphoneManager getLc], LinphoneMediaEncryptionSRTP)) { + NSMutableArray *titles = [NSMutableArray arrayWithArray:[dict objectForKey:@"Titles"]]; + [titles removeObject:@"SRTP"]; + [dict setObject:titles forKey:@"Titles"]; + NSMutableArray *values = [NSMutableArray arrayWithArray:[dict objectForKey:@"Values"]]; + [values removeObject:@"SRTP"]; + [dict setObject:values forKey:@"Values"]; + } + return [[[IASKSpecifier alloc] initWithSpecifier:dict] autorelease]; + } } #endif //HAVE_SSL return specifier; diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings index 784e448609bd1dba7d86e2cba65e3b86cadd2149..182d9e57e418745759e0cc8e49f7dcd7bf9fe6c9 100644 GIT binary patch delta 316 zcmZpg$arfCgfmKst>fpCJbb^BKy4a(N8tK(Sy3M<7-J zi-6Q2R2KmCqykN_Vu%5%Rb?nJI8c7xoF=|+1bw*>)RoeOkd8Q9N6=$*XKEPC@5({(}s D(dxA8HyNk859^w7%~`Afpi)}K0^)=<};K7~&3Gq2czp%f@x z#*he9SOSzt1hP{ZlEDhq!Pb|6jR!d=8K@S-D@C?$@<-v=$x&iFn;(g8Q8Ww!O6LNV zf(!wk4vJB2YFN?p}~{lEG%AfSp!M&_VW-8!e(Y&oH+W F1^|%{N5=pF delta 22 ecmaDblkwVA#tk<_Cs&DcZ4%$2xOsu4gD?Pfs|hav diff --git a/linphone.ldb/Contents.plist b/linphone.ldb/Contents.plist index 6f5bdfb7a..fd8042cc9 100644 --- a/linphone.ldb/Contents.plist +++ b/linphone.ldb/Contents.plist @@ -12175,7 +12175,7 @@ change date - 2012-12-06T16:35:25Z + 2013-01-14T08:36:33Z changed values class @@ -12185,7 +12185,7 @@ flags 0 hash - 5d8dda6d0a22dfa9f07da63202a55cbb + 8ce7c7423abd4610ddda73d40d929ed3 name Localizable.strings @@ -12944,6 +12944,34 @@ La cause était: %2$@ snapshots + + change date + 2001-01-01T00:00:00Z + changed values + + class + BLStringKeyObject + comment + No comment provided by engineer. + errors + + flags + 0 + key + Confirm the following SAS with the peer: +%s + localizations + + en + Confirm the following SAS with the peer: +%s + fr + Confirmer le SAS suivant avec l'interlocuteur: +%s + + snapshots + + change date 2001-01-01T00:00:00Z @@ -14071,6 +14099,31 @@ La cause était: %2$@ snapshots + + change date + 2001-01-01T00:00:00Z + changed values + + class + BLStringKeyObject + comment + No comment provided by engineer. + errors + + flags + 0 + key + Remove trust in the peer? + localizations + + en + Remove trust in the peer? + fr + Supprimer la confiance dans l'interlocuteur? + + snapshots + + change date 2001-01-01T00:00:00Z diff --git a/linphone.ldb/Resources/Resources/Localizable/1/Localizable.strings b/linphone.ldb/Resources/Resources/Localizable/1/Localizable.strings index 784e448609bd1dba7d86e2cba65e3b86cadd2149..182d9e57e418745759e0cc8e49f7dcd7bf9fe6c9 100644 GIT binary patch delta 316 zcmZpg$arfCgfmKst>fpCJbb^BKy4a(N8tK(Sy3M<7-J zi-6Q2R2KmCqykN_Vu%5%Rb?nJI8c7xoF=|+1bw*>)RoeOkd8Q9N6=$*XKEPC@5({(}s D