Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into xep-0363
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisballinger committed Jun 14, 2017
2 parents e5c7ef5 + 01b3fc0 commit 4865faf
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ChatSecure.xcodeproj/project.pbxproj
Expand Up @@ -482,7 +482,7 @@
D9B79BBA1ECF9FB500883963 /* Mantle.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D9B79BAD1ECF9F8700883963 /* Mantle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D9B79BBB1ECF9FCE00883963 /* Mantle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9B79BAD1ECF9F8700883963 /* Mantle.framework */; };
D9B7C5CE1EC3C9ED008D99E6 /* OTRAccountMigrator.m in Sources */ = {isa = PBXBuildFile; fileRef = D93718521EC267F800766D49 /* OTRAccountMigrator.m */; };
D9B7C5CF1EC3C9F2008D99E6 /* OTRAccountMigrator.h in Headers */ = {isa = PBXBuildFile; fileRef = D93718511EC267F800766D49 /* OTRAccountMigrator.h */; };
D9B7C5CF1EC3C9F2008D99E6 /* OTRAccountMigrator.h in Headers */ = {isa = PBXBuildFile; fileRef = D93718511EC267F800766D49 /* OTRAccountMigrator.h */; settings = {ATTRIBUTES = (Public, ); }; };
D9B9B1331DC7F3AC0007F5A7 /* UserInfoProfileCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B9B1311DC7F3AC0007F5A7 /* UserInfoProfileCell.swift */; };
D9B9B1351DC7F3BF0007F5A7 /* UserInfoProfileCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D9B9B1321DC7F3AC0007F5A7 /* UserInfoProfileCell.xib */; };
D9B9B1371DC802480007F5A7 /* OTRUserInfoProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = D9B9B1361DC802480007F5A7 /* OTRUserInfoProfile.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down
8 changes: 7 additions & 1 deletion ChatSecure/Classes/Controllers/XMPP/OTRXMPPRoomManager.m
Expand Up @@ -380,7 +380,7 @@ - (void)didSetupMappings:(OTRYapViewHandler *)handler
+ (NSXMLElement *)defaultRoomConfiguration
{
NSXMLElement *form = [[NSXMLElement alloc] initWithName:@"x" xmlns:@"jabber:x:data"];
[form addAttributeWithName:@"typ" stringValue:@"form"];
[form addAttributeWithName:@"type" stringValue:@"form"];

NSXMLElement *publicField = [[NSXMLElement alloc] initWithName:@"field"];
[publicField addAttributeWithName:@"var" stringValue:@"muc#roomconfig_publicroom"];
Expand All @@ -393,10 +393,16 @@ + (NSXMLElement *)defaultRoomConfiguration
NSXMLElement *whoisField = [[NSXMLElement alloc] initWithName:@"field"];
[publicField addAttributeWithName:@"var" stringValue:@"muc#roomconfig_whois"];
[publicField addChild:[[NSXMLElement alloc] initWithName:@"value" stringValue:@"anyone"]];

NSXMLElement *membersOnlyField = [[NSXMLElement alloc] initWithName:@"field"];
[membersOnlyField addAttributeWithName:@"var" stringValue:@"muc#roomconfig_membersonly"];
[membersOnlyField addChild:[[NSXMLElement alloc] initWithName:@"value" numberValue:@(1)]];


[form addChild:publicField];
[form addChild:persistentField];
[form addChild:whoisField];
[form addChild:membersOnlyField];

return form;
}
Expand Down
Expand Up @@ -44,6 +44,12 @@ - (void)setupGroupChat:(NSArray <NSString *>*)buddies account:(OTRAccount *)acco
[self setThreadKey:self.threadKey collection:[OTRXMPPRoom collection]];
}

// Override superclass since it will just return nil (the ThreadKey has not been set when this is called during setup).
- (nullable OTRAccount *)accountWithTransaction:(nonnull YapDatabaseReadTransaction *)transaction {
OTRAccount *account = [OTRAccount fetchObjectWithUniqueID:self.accountUniqueId transaction:transaction];
return account;
}

// Override superclass
- (void)setupInfoButton {
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"112-group" inBundle:[OTRAssets resourcesBundle] compatibleWithTraitCollection:nil] style:UIBarButtonItemStylePlain target:self action:@selector(didSelectOccupantsButton:)];
Expand Down
46 changes: 40 additions & 6 deletions ChatSecure/Classes/View Controllers/OTRMessagesViewController.m
Expand Up @@ -87,6 +87,7 @@ @interface OTRMessagesViewController () <UITextViewDelegate, OTRAttachmentPicker

@property (nonatomic, strong) NSTimer *lastSeenRefreshTimer;
@property (nonatomic, strong) UIView *jidForwardingHeaderView;
@property (nonatomic, strong) NSDataDetector *linkDetector;

@end

Expand Down Expand Up @@ -151,6 +152,7 @@ - (void)viewDidLoad
forState:UIControlStateNormal];

self.audioPlaybackController = [[OTRAudioPlaybackController alloc] init];
self.linkDetector = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil];

////// TextViewUpdates //////
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedTextViewChangedNotification:) name:UITextViewTextDidChangeNotification object:self.inputToolbar.contentView.textView];
Expand Down Expand Up @@ -1224,6 +1226,25 @@ - (UICollectionViewCell *)collectionView:(JSQMessagesCollectionView *)collection
}
}

// If we find any incoming migration link messages, show the "your friend has migrated" header
// to allow the user to start chatting with the new account instead.
if ([message messageIncoming]) {
[self.linkDetector enumerateMatchesInString:cell.textView.text options:kNilOptions range:NSMakeRange(0, [cell.textView.text length]) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
if (result.resultType == NSTextCheckingTypeLink)
{
if ([result.URL otr_isInviteLink]) {
// Migration link?
[result.URL otr_decodeShareLink:^(XMPPJID * _Nullable jid, NSArray<NSURLQueryItem *> * _Nullable queryItems) {
if ([NSURL otr_queryItemsContainMigrationHint:queryItems]) {
[self showJIDForwardingHeaderWithNewJID:jid];
}
}];
}
}
}];
}

cell.textView.delegate = self;
return cell;
}

Expand Down Expand Up @@ -1759,6 +1780,13 @@ - (void)didReceiveChanges:(OTRYapViewHandler *)handler sectionChanges:(NSArray<Y

- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
{
if ([URL otr_isInviteLink]) {
NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:NSUserActivityTypeBrowsingWeb];
activity.webpageURL = URL;
[[OTRAppDelegate appDelegate] application:[UIApplication sharedApplication] continueUserActivity:activity restorationHandler:nil];
return NO;
}

UIActivityViewController *activityViewController = [UIActivityViewController otr_linkActivityViewControllerWithURLs:@[URL]];

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
Expand Down Expand Up @@ -1819,10 +1847,20 @@ - (void)updateJIDForwardingHeader {
showHeader = YES;
}

if (showHeader && self.jidForwardingHeaderView == nil) {
if (showHeader) {
[self showJIDForwardingHeaderWithNewJID:forwardingJid];
} else if (!showHeader && self.jidForwardingHeaderView != nil) {
self.topContentAdditionalInset = 0;
[self.jidForwardingHeaderView removeFromSuperview];
self.jidForwardingHeaderView = nil;
}
}

- (void)showJIDForwardingHeaderWithNewJID:(XMPPJID *)newJid {
if (self.jidForwardingHeaderView == nil) {
UINib *nib = [UINib nibWithNibName:@"MigratedBuddyHeaderView" bundle:OTRAssets.resourcesBundle];
MigratedBuddyHeaderView *header = (MigratedBuddyHeaderView*)[nib instantiateWithOwner:self options:nil][0];
[header setForwardingJID:forwardingJid];
[header setForwardingJID:newJid];
[header.titleLabel setText:MIGRATED_BUDDY_STRING()];
[header.descriptionLabel setText:MIGRATED_BUDDY_INFO_STRING()];
[header.switchButton setTitle:MIGRATED_BUDDY_SWITCH() forState:UIControlStateNormal];
Expand All @@ -1832,10 +1870,6 @@ - (void)updateJIDForwardingHeader {
[self.view bringSubviewToFront:header];
self.jidForwardingHeaderView = header;
[self.view setNeedsLayout];
} else if (!showHeader && self.jidForwardingHeaderView != nil) {
self.topContentAdditionalInset = 0;
[self.jidForwardingHeaderView removeFromSuperview];
self.jidForwardingHeaderView = nil;
}
}

Expand Down
1 change: 1 addition & 0 deletions ChatSecureCore/ChatSecureCore.h
Expand Up @@ -84,6 +84,7 @@ FOUNDATION_EXPORT const unsigned char ChatSecureCoreVersionString[];
#import "OTRCertificatePinning.h"
#import "OTRXMPPServerInfo.h"
#import "XMPPPushModule.h"
#import "OTRAccountMigrator.h"

#import "OTRImageItem.h"
#import "OTRAudioItem.h"
Expand Down

0 comments on commit 4865faf

Please sign in to comment.