Add disable_chat_feature in configRC

This commit is contained in:
Benoit Martins 2023-05-02 15:47:01 +02:00
parent 30a916b514
commit 63fa4f10dd
11 changed files with 132 additions and 94 deletions

View file

@ -151,7 +151,7 @@
const LinphoneFriend* friend = linphone_search_result_get_friend(result);
const char *phoneNumber = linphone_search_result_get_phone_number(result);
if ([LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"] && ![self isSecureChatable:friend]) {
if (([LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"] && ![self isSecureChatable:friend]) || [LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"]) {
continue;
}

View file

@ -105,7 +105,7 @@ static UICompositeViewDescription *compositeDescription = nil;
}
if ([LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"]) {
if ([LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"] || [LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"]) {
_chiffreOptionView.hidden = true;
_isEncrypted = true;
_tableController.isEncrypted = true;
@ -159,7 +159,7 @@ static UICompositeViewDescription *compositeDescription = nil;
frame.origin.x = self.view.frame.size.width * 0.192;
}
_chiffreOptionView.frame = frame;
_isEncrypted = [LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"]; // false by default
_isEncrypted = [LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"] || [LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"]; // false by default
CGRect buttonFrame = _chiffreButton.frame;
if (!_isEncrypted) {

View file

@ -69,7 +69,7 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
_chatButton.hidden = [LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"];
_chatButton.hidden = [LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"] || [LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"];
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[self update];
}
@ -178,7 +178,7 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)shouldHideEncryptedChatView:(BOOL)hasLime {
_encryptedChatView.hidden = !hasLime;
_encryptedChatView.hidden = !hasLime || [LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"];
CGRect newFrame = _optionsView.frame;
if (!hasLime) {
newFrame.origin.x = _encryptedChatView.frame.size.width * 2/3;

View file

@ -240,7 +240,7 @@ struct codec_name_pref_table codec_pref_table[] = {{"speex", 8000, "speex_8k_pre
NSString *path = [[NSBundle mainBundle] pathForResource:@"msg" ofType:@"wav"];
self.messagePlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:path] error:nil];
_sounds.vibrate = kSystemSoundID_Vibrate;
//_sounds.vibrate = kSystemSoundID_Vibrate;
_logs = [[NSMutableArray alloc] init];
_pushDict = [[NSMutableDictionary alloc] init];
@ -254,6 +254,11 @@ struct codec_name_pref_table codec_pref_table[] = {{"speex", 8000, "speex_8k_pre
[self renameDefaultSettings];
[self copyDefaultSettings];
[self overrideDefaultSettings];
if (![self lpConfigBoolForKey:@"disable_chat_feature" withDefault:FALSE]) {
_sounds.vibrate = kSystemSoundID_Vibrate;
}
if (![self lpConfigBoolForKey:@"migration_images_done" withDefault:FALSE]) {
[self migrationAllImages];
}

View file

@ -76,16 +76,20 @@
- (void)update:(BOOL)appear {
[self updateSelectedButton:[PhoneMainView.instance currentView]];
[self updateMissedCall:linphone_core_get_missed_calls_count(LC) appear:appear];
[self updateUnreadMessage:appear];
if (![LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"]) {
[self updateUnreadMessage:appear];
}
}
- (void)updateUnreadMessage:(BOOL)appear {
int unreadMessage = [LinphoneManager unreadMessageCount];
if (unreadMessage > 0) {
_chatNotificationLabel.text = [NSString stringWithFormat:@"%i", unreadMessage];
[_chatNotificationView startAnimating:appear];
} else {
[_chatNotificationView stopAnimating:appear];
if (![LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"]) {
if (unreadMessage > 0) {
_chatNotificationLabel.text = [NSString stringWithFormat:@"%i", unreadMessage];
[_chatNotificationView startAnimating:appear];
} else {
[_chatNotificationView stopAnimating:appear];
}
}
}
@ -110,6 +114,24 @@
[view equal:ChatConversationInfoView.compositeViewDescription] ||
[view equal:ChatConversationImdnView.compositeViewDescription] ||
[view equal:ChatConversationView.compositeViewDescription];
if ([LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"] && [self viewIsCurrentlyPortrait]) {
CGFloat itemWidth = [UIScreen mainScreen].bounds.size.width/3;
[_chatButton setEnabled:false];
[_chatButton setHidden:true];
[_chatNotificationView setHidden:true];
_historyButton.frame = CGRectMake(0, 0, itemWidth, 66);
_contactsButton.frame = CGRectMake(itemWidth, 0, itemWidth, 66);
_dialerButton.frame = CGRectMake(itemWidth*2, 0, itemWidth, 66);
_selectedButtonImage.frame = CGRectMake(_selectedButtonImage.frame.origin.x, _selectedButtonImage.frame.origin.y, itemWidth, 3);
} else if ([LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"] && ![self viewIsCurrentlyPortrait]) {
[_chatButton setEnabled:false];
[_chatButton setHidden:true];
[_chatNotificationView setHidden:true];
_historyButton.frame = CGRectMake(0, 20, 90, 90);
_contactsButton.frame = CGRectMake(0, 120, 90, 90);
_dialerButton.frame = CGRectMake(0, 220, 90, 90);
_selectedButtonImage.frame = CGRectMake(_selectedButtonImage.frame.origin.x, _selectedButtonImage.frame.origin.y, 3, 90);
}
CGRect selectedNewFrame = _selectedButtonImage.frame;
if ([self viewIsCurrentlyPortrait]) {
selectedNewFrame.origin.x =

View file

@ -77,7 +77,7 @@
[FastAddressBook isSipURIValid:_addressLabel.text]));
self.inviteButton.hidden = !ENABLE_SMS_INVITE || [[contactDetailsView.contact sipAddresses] count] > 0 || !self.linphoneImage.hidden;
[self shouldHideEncryptedChatView:account && linphone_account_params_get_conference_factory_uri(linphone_account_get_params(account)) && model && linphone_presence_model_has_capability(model, LinphoneFriendCapabilityLimeX3dh)];
_chatButton.hidden = [LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"];
_chatButton.hidden = [LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"] || [LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"];
}
if (addr) {
@ -86,7 +86,7 @@
}
- (void)shouldHideEncryptedChatView:(BOOL)hasLime {
_encryptedChatView.hidden = !hasLime;
_encryptedChatView.hidden = !hasLime || [LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"];
CGRect newFrame = _optionsView.frame;
if (!hasLime) {
newFrame.origin.x = _addressLabel.frame.origin.x + _callButton.frame.size.width * 2/3;

View file

@ -669,6 +669,10 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
if (!linphone_core_ldap_available(LC)) {
[hiddenKeys addObject:@"contacts_menu"];
}
if ([LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"]){
[hiddenKeys addObject:@"message_menu"];
}
#ifndef DEBUG
[hiddenKeys addObject:@"debug_actions_group"];
[hiddenKeys addObject:@"release_button"];

View file

@ -22,13 +22,14 @@
import Foundation
import UIKit
import AVFoundation
import linphonesw
extension UIDevice {
static func ipad() -> Bool {
return UIDevice.current.userInterfaceIdiom == .pad
}
static func vibrate() {
if (!ipad()) {
if (!ipad() || Core.get().config?.getBool(section: "app", key: "disable_chat_feature", defaultValue: false) == false) {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
}
}

View file

@ -19,6 +19,8 @@ lime_migration_done=0
use_rls_presence=1
use_callkit=1
unexpected_pushkit=0
force_lime_chat_rooms=0
disable_chat_feature=0
[in_app_purchase]
#set to 1 if in-app purchases are to be shown in the application

View file

@ -28,6 +28,7 @@ use_callkit=1
accept_early_media=0
force_lime_chat_rooms=0
disable_chat_feature=0
enable_native_address_book=1
hide_link_phone_number=0

View file

@ -52,94 +52,97 @@ class NotificationService: UNNotificationServiceExtension {
}
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
NSLog("[msgNotificationService] start msgNotificationService extension")
if (VFSUtil.vfsEnabled(groupName: APP_GROUP_ID) && !VFSUtil.activateVFS()) {
VFSUtil.log("[VFS] Error unable to activate.", .error)
}
if let bestAttemptContent = bestAttemptContent {
createCore()
NotificationService.log.message(message: "received push payload : \(bestAttemptContent.userInfo.debugDescription)")
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
NSLog("[msgNotificationService] start msgNotificationService extension")
if (VFSUtil.vfsEnabled(groupName: APP_GROUP_ID) && !VFSUtil.activateVFS()) {
VFSUtil.log("[VFS] Error unable to activate.", .error)
}
let defaults = UserDefaults.init(suiteName: APP_GROUP_ID)
if let chatroomsPushStatus = defaults?.dictionary(forKey: "chatroomsPushStatus") {
let aps = bestAttemptContent.userInfo["aps"] as? NSDictionary
let alert = aps?["alert"] as? NSDictionary
let fromAddresses = alert?["loc-args"] as? [String]
if let bestAttemptContent = bestAttemptContent {
createCore()
if let from = fromAddresses?.first {
if ((chatroomsPushStatus[from] as? String) == "disabled") {
NotificationService.log.message(message: "message comes from a muted chatroom, ignore it")
contentHandler(UNNotificationContent())
}
}
}
if let chatRoomInviteAddr = bestAttemptContent.userInfo["chat-room-addr"] as? String, !chatRoomInviteAddr.isEmpty {
NotificationService.log.message(message: "fetch chat room for invite, addr: \(chatRoomInviteAddr)")
let chatRoom = lc!.getNewChatRoomFromConfAddr(chatRoomAddr: chatRoomInviteAddr)
if (!(lc!.config?.getBool(section: "app", key: "disable_chat_feature", defaultValue: true))!){
NotificationService.log.message(message: "received push payload : \(bestAttemptContent.userInfo.debugDescription)")
if let chatRoom = chatRoom {
stopCore()
NotificationService.log.message(message: "chat room invite received")
bestAttemptContent.title = NSLocalizedString("GC_MSG", comment: "")
if (chatRoom.hasCapability(mask:ChatRoomCapabilities.OneToOne.rawValue)) {
if (chatRoom.peerAddress?.displayName.isEmpty != true) {
bestAttemptContent.body = chatRoom.peerAddress!.displayName
} else {
bestAttemptContent.body = chatRoom.peerAddress!.username
let defaults = UserDefaults.init(suiteName: APP_GROUP_ID)
if let chatroomsPushStatus = defaults?.dictionary(forKey: "chatroomsPushStatus") {
let aps = bestAttemptContent.userInfo["aps"] as? NSDictionary
let alert = aps?["alert"] as? NSDictionary
let fromAddresses = alert?["loc-args"] as? [String]
if let from = fromAddresses?.first {
if ((chatroomsPushStatus[from] as? String) == "disabled") {
NotificationService.log.message(message: "message comes from a muted chatroom, ignore it")
contentHandler(UNNotificationContent())
}
}
} else {
bestAttemptContent.body = chatRoom.subject
}
if let chatRoomInviteAddr = bestAttemptContent.userInfo["chat-room-addr"] as? String, !chatRoomInviteAddr.isEmpty {
NotificationService.log.message(message: "fetch chat room for invite, addr: \(chatRoomInviteAddr)")
let chatRoom = lc!.getNewChatRoomFromConfAddr(chatRoomAddr: chatRoomInviteAddr)
bestAttemptContent.sound = UNNotificationSound(named: UNNotificationSoundName("msg.caf")) // TODO : temporary fix, to be removed after flexisip release
contentHandler(bestAttemptContent)
return
}
} else if let callId = bestAttemptContent.userInfo["call-id"] as? String {
NotificationService.log.message(message: "fetch msg for callid ["+callId+"]")
let message = lc!.getNewMessageFromCallid(callId: callId)
if let message = message {
let msgData = parseMessage(message: message)
// Extension only upates app's badge when main shared core is Off = extension's core is On.
// Otherwise, the app will update the badge.
if lc?.globalState == GlobalState.On, let badge = updateBadge() as NSNumber? {
bestAttemptContent.badge = badge
}
stopCore()
bestAttemptContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "msg.caf"))
bestAttemptContent.title = NSLocalizedString("Message received", comment: "")
if let subtitle = msgData?.subtitle {
bestAttemptContent.subtitle = subtitle
}
if let body = msgData?.body {
bestAttemptContent.body = body
}
bestAttemptContent.categoryIdentifier = "msg_cat"
bestAttemptContent.userInfo.updateValue(msgData?.callId as Any, forKey: "CallId")
bestAttemptContent.userInfo.updateValue(msgData?.from as Any, forKey: "from")
bestAttemptContent.userInfo.updateValue(msgData?.peerAddr as Any, forKey: "peer_addr")
bestAttemptContent.userInfo.updateValue(msgData?.localAddr as Any, forKey: "local_addr")
contentHandler(bestAttemptContent)
return
} else {
NotificationService.log.message(message: "Message not found for callid ["+callId+"]")
if let chatRoom = chatRoom {
stopCore()
NotificationService.log.message(message: "chat room invite received")
bestAttemptContent.title = NSLocalizedString("GC_MSG", comment: "")
if (chatRoom.hasCapability(mask:ChatRoomCapabilities.OneToOne.rawValue)) {
if (chatRoom.peerAddress?.displayName.isEmpty != true) {
bestAttemptContent.body = chatRoom.peerAddress!.displayName
} else {
bestAttemptContent.body = chatRoom.peerAddress!.username
}
} else {
bestAttemptContent.body = chatRoom.subject
}
bestAttemptContent.sound = UNNotificationSound(named: UNNotificationSoundName("msg.caf")) // TODO : temporary fix, to be removed after flexisip release
contentHandler(bestAttemptContent)
return
}
} else if let callId = bestAttemptContent.userInfo["call-id"] as? String {
NotificationService.log.message(message: "fetch msg for callid ["+callId+"]")
let message = lc!.getNewMessageFromCallid(callId: callId)
if let message = message {
let msgData = parseMessage(message: message)
// Extension only upates app's badge when main shared core is Off = extension's core is On.
// Otherwise, the app will update the badge.
if lc?.globalState == GlobalState.On, let badge = updateBadge() as NSNumber? {
bestAttemptContent.badge = badge
}
stopCore()
bestAttemptContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "msg.caf"))
bestAttemptContent.title = NSLocalizedString("Message received", comment: "")
if let subtitle = msgData?.subtitle {
bestAttemptContent.subtitle = subtitle
}
if let body = msgData?.body {
bestAttemptContent.body = body
}
bestAttemptContent.categoryIdentifier = "msg_cat"
bestAttemptContent.userInfo.updateValue(msgData?.callId as Any, forKey: "CallId")
bestAttemptContent.userInfo.updateValue(msgData?.from as Any, forKey: "from")
bestAttemptContent.userInfo.updateValue(msgData?.peerAddr as Any, forKey: "peer_addr")
bestAttemptContent.userInfo.updateValue(msgData?.localAddr as Any, forKey: "local_addr")
contentHandler(bestAttemptContent)
return
} else {
NotificationService.log.message(message: "Message not found for callid ["+callId+"]")
}
}
}
serviceExtensionTimeWillExpire()
}
serviceExtensionTimeWillExpire()
}
}
override func serviceExtensionTimeWillExpire() {