new ContactDetailView : enable the creation of an encrypted chatroom if it has the ability of lime

This commit is contained in:
Danmei Chen 2019-01-02 14:45:45 +01:00
parent 653e79e280
commit 38c389bf64
5 changed files with 87 additions and 34 deletions

View file

@ -18,8 +18,10 @@
<outlet property="deleteButton" destination="C2f-aP-xjR" id="sxr-th-6rq"/>
<outlet property="editTextfield" destination="dTn-Hc-bGM" id="bkN-xg-S9D"/>
<outlet property="editView" destination="rAa-qu-PDc" id="cGz-D2-GiI"/>
<outlet property="encryptedChatView" destination="ERg-IK-XJX" id="Aam-pm-R6d"/>
<outlet property="inviteButton" destination="lgb-5W-T0c" id="iOl-Fl-AXH"/>
<outlet property="linphoneImage" destination="ZaI-29-AOK" id="dY1-vO-spk"/>
<outlet property="optionsView" destination="Ffn-KZ-0pX" id="spM-xw-9ri"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
@ -59,32 +61,6 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="88"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="ZbV-2Z-b4y" userLabel="callButton" customClass="UIIconButton">
<rect key="frame" x="135" y="40" width="44" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<accessibility key="accessibilityConfiguration" label="Call"/>
<state key="normal" image="call_start_body_default.png">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="disabled" image="call_start_body_disabled.png"/>
<state key="highlighted" image="call_start_body_over.png"/>
<connections>
<action selector="onCallClick:" destination="-1" eventType="touchUpInside" id="nVk-zG-i8I"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="FDT-HY-OQZ" userLabel="chatButton" customClass="UIIconButton">
<rect key="frame" x="195" y="40" width="44" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<accessibility key="accessibilityConfiguration" label="Chat"/>
<state key="normal" image="chat_start_body_default.png">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="disabled" image="chat_start_body_disabled.png"/>
<state key="highlighted" image="chat_start_body_over.png"/>
<connections>
<action selector="onChatClick:" destination="-1" eventType="touchUpInside" id="tec-tH-uij"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="john.doe@sip.linphone.org" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="frB-ep-LWi" userLabel="addressLabel">
<rect key="frame" x="26" y="0.0" width="323" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
@ -108,6 +84,61 @@
<action selector="onSMSInviteClick:" destination="-1" eventType="touchUpInside" id="E8o-h2-mml"/>
</connections>
</button>
<view contentMode="scaleToFill" id="Ffn-KZ-0pX" userLabel="optionsView">
<rect key="frame" x="26" y="40" width="323" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="ZbV-2Z-b4y" userLabel="callButton" customClass="UIIconButton">
<rect key="frame" x="79" y="0.0" width="44" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<accessibility key="accessibilityConfiguration" label="Call"/>
<state key="normal" image="call_start_body_default.png">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="disabled" image="call_start_body_disabled.png"/>
<state key="highlighted" image="call_start_body_over.png"/>
<connections>
<action selector="onCallClick:" destination="-1" eventType="touchUpInside" id="nVk-zG-i8I"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="FDT-HY-OQZ" userLabel="chatButton" customClass="UIIconButton">
<rect key="frame" x="139" y="0.0" width="44" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<accessibility key="accessibilityConfiguration" label="Chat"/>
<state key="normal" image="chat_start_body_default.png">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="disabled" image="chat_start_body_disabled.png"/>
<state key="highlighted" image="chat_start_body_over.png"/>
<connections>
<action selector="onChatClick:" destination="-1" eventType="touchUpInside" id="tec-tH-uij"/>
</connections>
</button>
<view contentMode="scaleToFill" id="ERg-IK-XJX" userLabel="encryptedChatView">
<rect key="frame" x="199" y="0.0" width="44" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="Red-NG-DKu" userLabel="encryptedChatButton" customClass="UIIconButton">
<rect key="frame" x="0.0" y="0.0" width="44" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<accessibility key="accessibilityConfiguration" label="Chat"/>
<state key="normal" image="chat_start_body_default.png">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="disabled" image="chat_start_body_disabled.png"/>
<state key="highlighted" image="chat_start_body_over.png"/>
<connections>
<action selector="onEncrptedChatClick:" destination="-1" eventType="touchUpInside" id="5IN-7c-QWf"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" image="security_toogle_icon_green.png" id="Vk5-LN-LHu" userLabel="securityImage">
<rect key="frame" x="30" y="0.0" width="18" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
</subviews>
</view>
</subviews>
</view>
</subviews>
</view>
</subviews>
@ -127,5 +158,6 @@
<image name="delete_field_default.png" width="27" height="27"/>
<image name="delete_field_over.png" width="27" height="27"/>
<image name="linphone_user.png" width="26" height="26"/>
<image name="security_toogle_icon_green.png" width="21" height="24"/>
</resources>
</document>

View file

@ -38,6 +38,8 @@
@property (weak, nonatomic) IBOutlet UIImageView *linphoneImage;
@property (weak, nonatomic) UIView *waitView;
@property (strong, nonatomic) IBOutlet UIButton *inviteButton;
@property (weak, nonatomic) IBOutlet UIView *encryptedChatView;
@property (weak, nonatomic) IBOutlet UIView *optionsView;
- (id)initWithIdentifier:(NSString *)identifier;
- (void)setAddress:(NSString *)address;
@ -46,6 +48,7 @@
- (IBAction)onCallClick:(id)sender;
- (IBAction)onChatClick:(id)sender;
- (IBAction)onEncrptedChatClick:(id)sender;
- (IBAction)onDeleteClick:(id)sender;
- (IBAction)onSMSInviteClick:(id)sender;
@end

View file

@ -61,15 +61,16 @@
_linphoneImage.hidden = TRUE;
if (contact) {
const LinphonePresenceModel *model = contact.friend ? linphone_friend_get_presence_model_for_uri_or_tel(contact.friend, _addressLabel.text.UTF8String) : NULL;
self.linphoneImage.hidden =
!((contact.friend &&
linphone_presence_model_get_basic_status(linphone_friend_get_presence_model_for_uri_or_tel(
contact.friend, _addressLabel.text.UTF8String)) == LinphonePresenceBasicStatusOpen) ||
!((model && linphone_presence_model_get_basic_status(model) == LinphonePresenceBasicStatusOpen) ||
(!linphone_proxy_config_is_phone_number(linphone_core_get_default_proxy_config(LC),
_addressLabel.text.UTF8String) &&
[FastAddressBook isSipURIValid:_addressLabel.text]));
ContactDetailsView *contactDetailsView = VIEW(ContactDetailsView);
self.inviteButton.hidden = !ENABLE_SMS_INVITE || [[contactDetailsView.contact sipAddresses] count] > 0 || !self.linphoneImage.hidden;
[self shouldHideEncryptedChatView:model && linphone_presence_model_has_capability(model, LinphoneFriendCapabilityLimeX3dh)];
}
if (addr) {
@ -77,6 +78,18 @@
}
}
- (void)shouldHideEncryptedChatView:(BOOL)hasLime {
_encryptedChatView.hidden = !hasLime;
CGRect newFrame = _optionsView.frame;
if (!hasLime) {
newFrame.origin.x = _addressLabel.frame.origin.x + _callButton.frame.size.width * 2/3;
} else {
newFrame.origin.x = _addressLabel.frame.origin.x;
}
_optionsView.frame = newFrame;
}
- (void)shouldHideLinphoneImageOfAddress {
if (!_addressLabel.text) {
return;
@ -137,11 +150,16 @@
- (IBAction)onChatClick:(id)event {
LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:_addressLabel.text];
// TODO one button for chatroom encrypted,another button for chatroom unencrypted
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:TRUE];
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:FALSE];
linphone_address_destroy(addr);
}
- (IBAction)onEncrptedChatClick:(id)sender {
LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:_addressLabel.text];
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:TRUE];
linphone_address_destroy(addr);
}
- (IBAction)onDeleteClick:(id)sender {
UITableView *tableView = VIEW(ContactDetailsView).tableController.tableView;
NSIndexPath *indexPath = [tableView indexPathForCell:self];

View file

@ -866,7 +866,7 @@ static RootViewManager *rootViewManagerInstance = nil;
}
const LinphoneAddress *local = linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(LC));
LinphoneChatRoom *room = linphone_core_find_one_to_one_chat_room(LC, local, remoteAddress);
LinphoneChatRoom *room = linphone_core_find_one_to_one_chat_room_2(LC, local, remoteAddress, isEncrypted);
if (!room) {
bctbx_list_t *addresses = bctbx_list_new((void*)remoteAddress);
[self createChatRoomWithSubject:LINPHONE_DUMMY_SUBJECT addresses:addresses andWaitView:waitView isEncrypted:isEncrypted];

View file

@ -36,7 +36,7 @@ sip_random_port=0
#whether SIP passwords must be encrypted in configuration storage file
store_ha1_passwd=0
deliver_imdn=1
linphone_specs=groupchat
linphone_specs=groupchat,lime
#to avoid app to not detect broken sockets when in long running task.
tcp_tls_keepalive=30000
@ -60,7 +60,7 @@ display_filter_auto_rotate=0
[lime]
lime_v2=1
x3dh_server_url=http://54.37.202.229:8082/flexisip-account-manager/x3dh-25519.php
x3dh_server_url=http://54.36.232.93:8082/flexisip-account-manager/x3dh-25519.php
lime_update_threshold=86400
max_nb_device_per_participant=255
allow_message_in_unsafe_chatroom=1