Add LIME to settings + manage LIME when sending messages

This commit is contained in:
Benjamin Reis 2017-01-09 17:20:00 +01:00
parent 25311fb8dd
commit 7603a61f7b
13 changed files with 155 additions and 30 deletions

View file

@ -240,6 +240,10 @@ static UICompositeViewDescription *compositeDescription = nil;
linphone_chat_message_unref(msg);
[_tableController scrollToBottom:true];
if(linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(_chatRoom)) {
[LinphoneManager.instance alertLIME:_chatRoom];
}
return TRUE;
}

View file

@ -271,7 +271,6 @@
actions:[NSArray arrayWithObjects:act_confirm, act_deny, nil]
intentIdentifiers:[[NSMutableArray alloc] init]
options:UNNotificationCategoryOptionCustomDismissAction];
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
[[UNUserNotificationCenter currentNotificationCenter]
requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound |
@ -708,6 +707,10 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
if (room) {
LinphoneChatMessage *msg = linphone_chat_room_create_message(room, replyText.UTF8String);
linphone_chat_room_send_chat_message(room, msg);
if(linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(room)) {
[LinphoneManager.instance alertLIME:room];
}
linphone_chat_room_mark_as_read(room);
TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController
getCachedController:NSStringFromClass(TabBarView.class)];
@ -750,6 +753,8 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
if (linphone_core_get_current_call(LC) == call) {
linphone_call_set_authentication_token_verified(call, NO);
}
} else if ([response.actionIdentifier isEqual:@"Call"]) {
} else { // in this case the value is : com.apple.UNNotificationDefaultActionIdentifier
if ([response.notification.request.content.categoryIdentifier isEqual:@"call_cat"]) {
[PhoneMainView.instance displayIncomingCall:call];
@ -898,6 +903,11 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
if (room) {
LinphoneChatMessage *msg = linphone_chat_room_create_message(room, replyText.UTF8String);
linphone_chat_room_send_chat_message(room, msg);
if(linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(room)) {
[LinphoneManager.instance alertLIME:room];
}
linphone_chat_room_mark_as_read(room);
[PhoneMainView.instance updateApplicationBadgeNumber];
}

View file

@ -323,6 +323,12 @@
[self setBool:[lm lpConfigBoolForKey:@"repeat_call_notification"]
forKey:@"repeat_call_notification_preference"];
}
// chat section
{
[self setInteger:linphone_core_lime_enabled(LC) forKey:@"use_lime_preference"];
[self setCString:linphone_core_get_file_transfer_server(LC) forKey:@"file_transfer_server_url_preference"];
}
// network section
{
@ -409,7 +415,6 @@
[self setCString:linphone_address_get_username(parsed) forKey:@"primary_username_preference"];
linphone_address_destroy(parsed);
}
[self setCString:linphone_core_get_file_transfer_server(LC) forKey:@"file_transfer_server_url_preference"];
}
changedDict = [[NSMutableDictionary alloc] init];
@ -742,6 +747,29 @@
[lm lpConfigSetBool:[self boolForKey:@"repeat_call_notification_preference"]
forKey:@"repeat_call_notification"];
}
// chat section
{
int val = [self integerForKey:@"use_lime_preference"];
linphone_core_enable_lime(LC, val);
if(val == LinphoneLimeMandatory && (linphone_core_get_media_encryption(LC) != LinphoneMediaEncryptionZRTP)) {
linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionZRTP);
[self setCString:"ZRTP" forKey:@"media_encryption_preference"];
UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"ZRTP activation", nil)
message:NSLocalizedString(@"LIME requires ZRTP encryption.\n"
@"By activating LIME you automatically ZRTP media encryption.",
nil)
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
[errView addAction:defaultAction];
[PhoneMainView.instance presentViewController:errView animated:YES completion:nil];
}
linphone_core_set_file_transfer_server(
LC, [[self stringForKey:@"file_transfer_server_url_preference"] UTF8String]);
}
// network section
{
@ -878,9 +906,6 @@
[lm lpConfigSetInt:[self integerForKey:@"account_mandatory_advanced_preference"]
forKey:@"account_mandatory_advanced_preference"];
linphone_core_set_file_transfer_server(
LC, [[self stringForKey:@"file_transfer_server_url_preference"] UTF8String]);
}
changedDict = [[NSMutableDictionary alloc] init];

View file

@ -140,6 +140,7 @@ typedef struct _LinphoneManagerSounds {
- (void)acceptCallForCallId:(NSString*)callid;
- (LinphoneCall *)callByCallId:(NSString *)call_id;
- (void)cancelLocalNotifTimerForCallId:(NSString*)callid;
- (void) alertLIME:(LinphoneChatRoom *)room;
+ (BOOL)langageDirectionIsRTL;
+ (void)kickOffNetworkConnection;

View file

@ -1360,6 +1360,27 @@ static void linphone_iphone_call_encryption_changed(LinphoneCore *lc, LinphoneCa
}
#pragma mark - Message composition start
- (void) alertLIME:(LinphoneChatRoom *)room {
UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"LIME Error", nil)
message:NSLocalizedString(@"You are trying to send a message using LIME to a contact not verified by ZRTP.\n"
@"Please call this contact and verify his ZRTP key before sending your messages.",
nil)
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
[errView addAction:defaultAction];
UIAlertAction* callAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Call", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self call:linphone_chat_room_get_peer_address(room)];
}];
[errView addAction:callAction];
[PhoneMainView.instance presentViewController:errView animated:YES completion:nil];
}
- (void)onMessageComposeReceived:(LinphoneCore *)core forRoom:(LinphoneChatRoom *)room {
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneTextComposeEvent

View file

@ -593,6 +593,10 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
if (!linphone_core_sip_transport_supported(LC, LinphoneTransportTls)) {
[hiddenKeys addObject:@"media_encryption_preference"];
}
if(!linphone_core_lime_available(LC)) {
[hiddenKeys addObject:@"use_lime_preference"];
}
#ifndef DEBUG
[hiddenKeys addObject:@"debug_actions_group"];

View file

@ -9,6 +9,7 @@
#import "FileTransferDelegate.h"
#import "Utils.h"
#import "PhoneMainView.h"
#import "LinphoneManager.h"
@interface FileTransferDelegate ()
@property(strong) NSMutableData *data;
@ -171,8 +172,12 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
}
LOGI(@"%p Uploading content from message %p", self, _message);
linphone_chat_room_send_chat_message(chatRoom, _message);
if(linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(chatRoom)) {
[LinphoneManager.instance alertLIME:chatRoom];
}
}
- (BOOL)download:(LinphoneChatMessage *)message {

View file

@ -160,28 +160,6 @@
<key>IASKTextAlignment</key>
<string>IASKUITextAlignmentRight</string>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>File sharing</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>KeyboardType</key>
<string>URL</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Server URL</string>
<key>Key</key>
<string>file_transfer_server_url_preference</string>
<key>IASKTextAlignment</key>
<string>IASKUITextAlignmentRight</string>
</dict>
</array>
</dict>
</plist>

View file

@ -114,6 +114,16 @@
<key>Type</key>
<string>PSChildPaneSpecifier</string>
</dict>
<dict>
<key>Type</key>
<string>PSChildPaneSpecifier</string>
<key>Key</key>
<string>message_menu</string>
<key>Title</key>
<string>Chat</string>
<key>File</key>
<string>Message</string>
</dict>
<dict>
<key>Key</key>
<string>network_menu</string>

View file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>DefaultValue</key>
<string>0</string>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Titles</key>
<array>
<string>Disabled</string>
<string>Preferred</string>
<string>Mandatory</string>
</array>
<key>Values</key>
<array>
<integer>0</integer>
<integer>2</integer>
<integer>1</integer>
</array>
<key>Title</key>
<string>Encrypt messages with LIME</string>
<key>Key</key>
<string>use_lime_preference</string>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>File sharing</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>KeyboardType</key>
<string>URL</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Server URL</string>
<key>Key</key>
<string>file_transfer_server_url_preference</string>
<key>IASKTextAlignment</key>
<string>IASKUITextAlignmentRight</string>
</dict>
</array>
</dict>
</plist>

14
Settings/message.plist Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
message.plist
linphone
Created by REIS Benjamin on 09/01/2017.
Copyright (c) 2017 __MyCompanyName__. All rights reserved.
-->
<plist version="1.0">
<dict>
</dict>
</plist>

@ -1 +1 @@
Subproject commit 63e61b0ae0f20e6d9f790335184fa4a0fc2a90ab
Subproject commit f5a8603f8e379486d3a4bfa4d74861b0a2d880dd

@ -1 +1 @@
Subproject commit 1c92cdd4466d8af34ff3faa1db7e2e3f0c8f5d46
Subproject commit 2751c8a703152f553247aa96d7b6d3ba72f4c4b1