Fix media encryption choose issue

Add security state image
This commit is contained in:
Yann Diorcet 2012-07-19 11:30:08 +02:00
parent 36d144156f
commit c11f21a63f
4 changed files with 101 additions and 7 deletions

View file

@ -361,9 +361,9 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
linphone_core_enable_video(lc, enableVideo, enableVideo);
NSString *menc = [self stringForKey:@"media_encryption_preference"];
if (menc && [menc compare:@"SRTP"])
if (menc && [menc compare:@"SRTP"] == NSOrderedSame)
linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionSRTP);
else if (menc && [menc compare:@"ZRTP"])
else if (menc && [menc compare:@"ZRTP"] == NSOrderedSame)
linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionZRTP);
else linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionNone);

View file

@ -23,10 +23,12 @@
UIImageView* registrationStateImage;
UILabel* registrationStateLabel;
UIImageView* callQualityImage;
UIImageView* callSecurityImage;
}
@property (nonatomic, retain) IBOutlet UIImageView* registrationStateImage;
@property (nonatomic, retain) IBOutlet UILabel* registrationStateLabel;
@property (nonatomic, retain) IBOutlet UIImageView* callQualityImage;
@property (nonatomic, retain) IBOutlet UIImageView* callSecurityImage;
@end

View file

@ -27,14 +27,21 @@
@synthesize registrationStateImage;
@synthesize registrationStateLabel;
@synthesize callQualityImage;
@synthesize callSecurityImage;
NSTimer *callQualityTimer;
NSTimer *callSecurityTimer;
#pragma mark - Lifecycle Functions
- (id)init {
return [super initWithNibName:@"UIStateBar" bundle:[NSBundle mainBundle]];
self = [super initWithNibName:@"UIStateBar" bundle:[NSBundle mainBundle]];
if(self != nil) {
self->callSecurityImage = nil;
self->callQualityImage = nil;
}
return self;
}
- (void) dealloc {
@ -57,6 +64,13 @@ NSTimer *callQualityTimer;
userInfo:nil
repeats:YES];
// Set callQualityTimer
callSecurityTimer = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(callSecurityUpdate)
userInfo:nil
repeats:YES];
// Set observer
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(registrationUpdate:)
@ -65,6 +79,7 @@ NSTimer *callQualityTimer;
[callQualityImage setHidden: true];
[callSecurityImage setHidden: true];
// Update to default state
LinphoneProxyConfig* config = NULL;
@ -81,7 +96,14 @@ NSTimer *callQualityTimer;
name:@"LinphoneRegistrationUpdate"
object:nil];
[callQualityTimer invalidate];
if(callQualityTimer != nil) {
[callQualityTimer invalidate];
callQualityTimer = nil;
}
if(callQualityTimer != nil) {
[callSecurityTimer invalidate];
callSecurityTimer = nil;
}
}
@ -157,6 +179,44 @@ NSTimer *callQualityTimer;
#pragma mark -
- (void)callSecurityUpdate {
BOOL pending = false;
BOOL security = true;
if(![LinphoneManager isLcReady]) {
[callSecurityImage setHidden: true];
return;
}
const MSList *list = linphone_core_get_calls([LinphoneManager getLc]);
if(list == NULL) {
[callSecurityImage setHidden: true];
return;
}
while(list != NULL) {
LinphoneCall *call = (LinphoneCall*) list->data;
LinphoneMediaEncryption enc = linphone_call_params_get_media_encryption(linphone_call_get_current_params(call));
if(enc == LinphoneMediaEncryptionNone)
security = false;
else if(enc == LinphoneMediaEncryptionZRTP) {
if(!linphone_call_get_authentication_token_verified(call)) {
pending = true;
}
}
list = list->next;
}
if(security) {
if(pending) {
[callSecurityImage setImage:[UIImage imageNamed:@"security_pending.png"]];
} else {
[callSecurityImage setImage:[UIImage imageNamed:@"security_ok.png"]];
}
} else {
[callSecurityImage setImage:[UIImage imageNamed:@"security_ko.png"]];
}
[callSecurityImage setHidden: false];
}
- (void)callQualityUpdate {
UIImage *image = nil;
if([LinphoneManager isLcReady]) {

View file

@ -103,11 +103,22 @@
<string key="NSFrame">{{219, 3}, {27, 17}}</string>
<reference key="NSSuperview" ref="848661322"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<reference key="NSNextKeyView" ref="522045680"/>
<string key="NSReuseIdentifierKey">_NS:567</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIImageView" id="522045680">
<reference key="NSNextResponder" ref="848661322"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{254, 3}, {27, 17}}</string>
<reference key="NSSuperview" ref="848661322"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:567</string>
<int key="IBUIContentMode">1</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</array>
<string key="NSFrameSize">{320, 23}</string>
<reference key="NSSuperview"/>
@ -155,6 +166,14 @@
</object>
<int key="connectionID">16</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">callSecurityImage</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="522045680"/>
</object>
<int key="connectionID">18</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@ -183,6 +202,7 @@
<reference ref="200467549"/>
<reference ref="393098359"/>
<reference ref="327031870"/>
<reference ref="522045680"/>
</array>
<reference key="parent" ref="0"/>
</object>
@ -208,7 +228,13 @@
<int key="objectID">13</int>
<reference key="object" ref="327031870"/>
<reference key="parent" ref="848661322"/>
<string key="objectName">callQualityIndicatorImage</string>
<string key="objectName">callQualityImage</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">17</int>
<reference key="object" ref="522045680"/>
<reference key="parent" ref="848661322"/>
<string key="objectName">callSecurityImage</string>
</object>
</array>
</object>
@ -219,6 +245,7 @@
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="12.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="13.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="17.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@ -227,7 +254,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">16</int>
<int key="maxID">18</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -236,6 +263,7 @@
<string key="superclassName">UIViewController</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="callQualityImage">UIImageView</string>
<string key="callSecurityImage">UIImageView</string>
<string key="registrationStateImage">UIImageView</string>
<string key="registrationStateLabel">UILabel</string>
</dictionary>
@ -244,6 +272,10 @@
<string key="name">callQualityImage</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo" key="callSecurityImage">
<string key="name">callSecurityImage</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo" key="registrationStateImage">
<string key="name">registrationStateImage</string>
<string key="candidateClassName">UIImageView</string>