Skip to content

Commit

Permalink
Group functionality
Browse files Browse the repository at this point in the history
• create
• send/receive full functionality
• basic UI for group updating.

TODOS:
    -group avatars not supported
    -group update occurrence initiated by Android displayed in thread UI but not yet fully

Reviewed-by: @FredericJacobs
  • Loading branch information
corbett authored and FredericJacobs committed Dec 23, 2014
1 parent 9599ec1 commit 312423a
Show file tree
Hide file tree
Showing 27 changed files with 403 additions and 290 deletions.
12 changes: 0 additions & 12 deletions Signal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,12 @@
B6B096631A1D25ED008BFAA6 /* TSPreKeyManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B095F11A1D25ED008BFAA6 /* TSPreKeyManager.m */; };
B6B096641A1D25ED008BFAA6 /* TSContactThread.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B095F51A1D25ED008BFAA6 /* TSContactThread.m */; };
B6B096651A1D25ED008BFAA6 /* TSGroupThread.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B095F71A1D25ED008BFAA6 /* TSGroupThread.m */; };
B6B096671A1D25ED008BFAA6 /* TSGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B095FB1A1D25ED008BFAA6 /* TSGroup.m */; };
B6B096681A1D25ED008BFAA6 /* TSRecipient.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B095FD1A1D25ED008BFAA6 /* TSRecipient.m */; };
B6B096691A1D25ED008BFAA6 /* TSThread.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B095FF1A1D25ED008BFAA6 /* TSThread.m */; };
B6B0966A1A1D25ED008BFAA6 /* IncomingPushMessageSignal.pb.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B096021A1D25ED008BFAA6 /* IncomingPushMessageSignal.pb.m */; settings = {COMPILER_FLAGS = "-w"; }; };
B6B0966B1A1D25ED008BFAA6 /* TSAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B096041A1D25ED008BFAA6 /* TSAttachment.m */; };
B6B0966C1A1D25ED008BFAA6 /* TSCall.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B096061A1D25ED008BFAA6 /* TSCall.m */; };
B6B0966D1A1D25ED008BFAA6 /* TSErrorMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B096081A1D25ED008BFAA6 /* TSErrorMessage.m */; };
B6B0966E1A1D25ED008BFAA6 /* TSGroupMessageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B0960A1A1D25ED008BFAA6 /* TSGroupMessageManager.m */; };
B6B0966F1A1D25ED008BFAA6 /* TSIncomingMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B0960C1A1D25ED008BFAA6 /* TSIncomingMessage.m */; };
B6B096701A1D25ED008BFAA6 /* TSInfoMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B0960E1A1D25ED008BFAA6 /* TSInfoMessage.m */; };
B6B096711A1D25ED008BFAA6 /* TSInteraction.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B096101A1D25ED008BFAA6 /* TSInteraction.m */; };
Expand Down Expand Up @@ -995,8 +993,6 @@
B6B095F51A1D25ED008BFAA6 /* TSContactThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSContactThread.m; sourceTree = "<group>"; };
B6B095F61A1D25ED008BFAA6 /* TSGroupThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSGroupThread.h; sourceTree = "<group>"; };
B6B095F71A1D25ED008BFAA6 /* TSGroupThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSGroupThread.m; sourceTree = "<group>"; };
B6B095FA1A1D25ED008BFAA6 /* TSGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSGroup.h; sourceTree = "<group>"; };
B6B095FB1A1D25ED008BFAA6 /* TSGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSGroup.m; sourceTree = "<group>"; };
B6B095FC1A1D25ED008BFAA6 /* TSRecipient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSRecipient.h; sourceTree = "<group>"; };
B6B095FD1A1D25ED008BFAA6 /* TSRecipient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSRecipient.m; sourceTree = "<group>"; };
B6B095FE1A1D25ED008BFAA6 /* TSThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TSThread.h; path = ../TSThread.h; sourceTree = "<group>"; };
Expand All @@ -1009,8 +1005,6 @@
B6B096061A1D25ED008BFAA6 /* TSCall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSCall.m; sourceTree = "<group>"; };
B6B096071A1D25ED008BFAA6 /* TSErrorMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSErrorMessage.h; sourceTree = "<group>"; };
B6B096081A1D25ED008BFAA6 /* TSErrorMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSErrorMessage.m; sourceTree = "<group>"; };
B6B096091A1D25ED008BFAA6 /* TSGroupMessageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSGroupMessageManager.h; sourceTree = "<group>"; };
B6B0960A1A1D25ED008BFAA6 /* TSGroupMessageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSGroupMessageManager.m; sourceTree = "<group>"; };
B6B0960B1A1D25ED008BFAA6 /* TSIncomingMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSIncomingMessage.h; sourceTree = "<group>"; };
B6B0960C1A1D25ED008BFAA6 /* TSIncomingMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSIncomingMessage.m; sourceTree = "<group>"; };
B6B0960D1A1D25ED008BFAA6 /* TSInfoMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSInfoMessage.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2335,8 +2329,6 @@
isa = PBXGroup;
children = (
B6B095F31A1D25ED008BFAA6 /* Threads */,
B6B095FA1A1D25ED008BFAA6 /* TSGroup.h */,
B6B095FB1A1D25ED008BFAA6 /* TSGroup.m */,
B6B095FC1A1D25ED008BFAA6 /* TSRecipient.h */,
B6B095FD1A1D25ED008BFAA6 /* TSRecipient.m */,
);
Expand Down Expand Up @@ -2366,8 +2358,6 @@
B6B096061A1D25ED008BFAA6 /* TSCall.m */,
B6B096071A1D25ED008BFAA6 /* TSErrorMessage.h */,
B6B096081A1D25ED008BFAA6 /* TSErrorMessage.m */,
B6B096091A1D25ED008BFAA6 /* TSGroupMessageManager.h */,
B6B0960A1A1D25ED008BFAA6 /* TSGroupMessageManager.m */,
B6B0960B1A1D25ED008BFAA6 /* TSIncomingMessage.h */,
B6B0960C1A1D25ED008BFAA6 /* TSIncomingMessage.m */,
B6B0960D1A1D25ED008BFAA6 /* TSInfoMessage.h */,
Expand Down Expand Up @@ -3108,7 +3098,6 @@
76EB061A18170B33006006FC /* DiscardingLog.m in Sources */,
B63AF5C71A1F757900D01AAD /* TSContactsIntersectionRequest.m in Sources */,
B6B0968B1A1D25ED008BFAA6 /* TSStorageManager+SignedPreKeyStore.m in Sources */,
B6B0966E1A1D25ED008BFAA6 /* TSGroupMessageManager.m in Sources */,
76EB05AC18170B33006006FC /* SrtpSocket.m in Sources */,
B6CBF53F1A254BD1000D4184 /* ContactDetailCell.m in Sources */,
FCB11D931A12A4AA002F93FB /* FullImageViewController.m in Sources */,
Expand Down Expand Up @@ -3151,7 +3140,6 @@
76EB063A18170B33006006FC /* FunctionalUtil.m in Sources */,
76EB060A18170B33006006FC /* SignalUtil.m in Sources */,
76EB062818170B33006006FC /* BadArgument.m in Sources */,
B6B096671A1D25ED008BFAA6 /* TSGroup.m in Sources */,
76EB062E18170B33006006FC /* SecurityFailure.m in Sources */,
76EB05F218170B33006006FC /* PhoneNumber.m in Sources */,
E197B61718BBEC1A00F073E5 /* AnonymousAudioCallbackHandler.m in Sources */,
Expand Down
8 changes: 6 additions & 2 deletions Signal/src/Storyboard/Storyboard.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
</view>
<connections>
<segue destination="urv-62-RsD" kind="presentation" identifier="fingerprintSegue" modalPresentationStyle="overCurrentContext" animates="NO" id="Zjl-QX-tHE"/>
<segue destination="bDi-2Q-XOC" kind="show" identifier="updateGroupSegue" id="gZ1-lh-srF"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yXZ-iE-5va" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down Expand Up @@ -3404,7 +3405,7 @@ Licensed under the GPLv3</string>
<placeholder placeholderIdentifier="IBFirstResponder" id="fUD-iU-Cax" userLabel="First Responder" sceneMemberID="firstResponder"/>
<searchDisplayController id="f1M-Dk-nMv"/>
</objects>
<point key="canvasLocation" x="3082.5" y="-906.75"/>
<point key="canvasLocation" x="3184.5" y="-906.75"/>
</scene>
<!--New Group View Controller-->
<scene sceneID="mdV-ti-fPA">
Expand Down Expand Up @@ -3612,7 +3613,7 @@ Licensed under the GPLv3</string>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="GsM-dR-L7j" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3930" y="-906.75"/>
<point key="canvasLocation" x="4197" y="-899.25"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="kfT-eG-hkf">
Expand Down Expand Up @@ -3657,4 +3658,7 @@ Licensed under the GPLv3</string>
<image name="signal.png" width="50" height="50"/>
<image name="signals_tab.png" width="24" height="24"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="gZ1-lh-srF"/>
</inferredMetricsTieBreakers>
</document>
4 changes: 3 additions & 1 deletion Signal/src/environment/Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#import "PropertyListPreferences.h"
#import "PacketHandler.h"
#import "SecureEndPoint.h"

#import "GroupModel.h"
/**
*
* Environment is a data and data accessor class.
Expand Down Expand Up @@ -85,5 +85,7 @@ andCurrentRegionCodeForPhoneNumbers:(NSString*)currentRegionCodeForPhoneNumbers
- (void)setSignUpFlowNavigationController:(UINavigationController *)signUpFlowNavigationController;

+ (void)messageIdentifier:(NSString*)identifier;
+ (void)groupModel:(GroupModel*)model;


@end
20 changes: 20 additions & 0 deletions Signal/src/environment/Environment.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,26 @@ + (void)messageIdentifier:(NSString*)identifier{
}
}

+ (void)groupModel:(GroupModel*)model {
Environment *env = [self getCurrent];
SignalsViewController *vc = env.signalsViewController;

if (vc.presentedViewController) {
[vc.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}

[vc.navigationController popToRootViewControllerAnimated:YES];
vc.groupFromCompose = model;
[vc performSegueWithIdentifier:@"showSegue" sender:nil];

UITabBarController *tabBarController = (UITabBarController*)vc.parentViewController.parentViewController;
if ([tabBarController respondsToSelector:@selector(selectedIndex)]) {
tabBarController.selectedIndex = 1;
}

}


+ (void)resetAppData{
[SignalKeyingStorage wipeKeychain];
[Environment.preferences clear];
Expand Down
27 changes: 0 additions & 27 deletions Signal/src/textsecure/Contacts/TSGroup.h

This file was deleted.

17 changes: 0 additions & 17 deletions Signal/src/textsecure/Contacts/TSGroup.m

This file was deleted.

1 change: 0 additions & 1 deletion Signal/src/textsecure/Contacts/TSThread.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#import "ContactsManager.h"
#import "TSInteraction.h"
#import "TSStorageManager.h"
#import "TSGroup.h"

#import "TSCall.h"
#import "TSOutgoingMessage.h"
Expand Down
6 changes: 4 additions & 2 deletions Signal/src/textsecure/Contacts/Threads/TSGroupThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
//

#import "TSThread.h"
#import "GroupModel.h"

@interface TSGroupThread : TSThread

+ (instancetype)threadWithGroupId:(NSData*)groupId;
@property (nonatomic,strong) GroupModel* groupModel;
+ (instancetype)threadWithGroupModel:(GroupModel *)groupModel transaction:(YapDatabaseReadWriteTransaction*)transaction;

- (NSData*)groupId;
- (NSArray *)recipientsWithTransaction:(YapDatabaseReadTransaction*)transaction;

@end
46 changes: 36 additions & 10 deletions Signal/src/textsecure/Contacts/Threads/TSGroupThread.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,34 @@
//

#import "TSGroupThread.h"
#import "TSRecipient.h"
#import "NSData+Base64.h"

@implementation TSGroupThread

#define TSGroupThreadPrefix @"g"

- (instancetype)initWithGroupId:(NSData*)groupId{
- (instancetype)initWithGroupModel:(GroupModel *)groupModel{

NSString *uniqueIdentifier = [[self class] threadIdFromGroupId:groupId];
NSString *uniqueIdentifier = [[self class] threadIdFromGroupId:groupModel.groupId];

self = [super initWithUniqueId:uniqueIdentifier];

_groupModel = groupModel;
return self;
}

+ (instancetype)threadWithGroupId:(NSData *)groupId{
TSGroupThread *thread = [self fetchObjectWithUniqueID:[self threadIdFromGroupId:groupId]];

+ (instancetype)threadWithGroupModel:(GroupModel *)groupModel transaction:(YapDatabaseReadWriteTransaction*)transaction{
TSGroupThread *thread = [self fetchObjectWithUniqueID:[self threadIdFromGroupId:groupModel.groupId] transaction:transaction];

if (!thread) {
thread = [[TSGroupThread alloc] initWithGroupId:groupId];
[thread save];
thread = [[TSGroupThread alloc] initWithGroupModel:groupModel];
[thread saveWithTransaction:transaction];
}
else if(![thread.groupModel isEqual:groupModel]) {
thread.groupModel = groupModel;
[thread saveWithTransaction:transaction];
}

return thread;
}

Expand All @@ -42,6 +46,12 @@ - (NSData *)groupId{
return [[self class] groupIdFromThreadId:self.uniqueId];
}


- (NSString*)name{
return self.groupModel.groupName;
}


+ (NSString*)threadIdFromGroupId:(NSData*)groupId{
return [TSGroupThreadPrefix stringByAppendingString:[groupId base64EncodedString]];
}
Expand All @@ -50,4 +60,20 @@ + (NSData*)groupIdFromThreadId:(NSString*)threadId{
return [NSData dataFromBase64String:[threadId substringWithRange:NSMakeRange(1, threadId.length-1)]];
}



- (NSArray *)recipientsWithTransaction:(YapDatabaseReadTransaction*)transaction{
NSMutableArray *recipients = [[NSMutableArray alloc] init];

for(NSString *recipientId in _groupModel.groupMemberIds) {
TSRecipient *recipient = [TSRecipient recipientWithTextSecureIdentifier:recipientId withTransaction:transaction];
if (!recipient){
recipient = [[TSRecipient alloc] initWithTextSecureIdentifier:recipientId relay:nil];
}
[recipients addObject:recipient];
}
return recipients;
}


@end
17 changes: 0 additions & 17 deletions Signal/src/textsecure/Messages/TSGroupMessageManager.h

This file was deleted.

Loading

0 comments on commit 312423a

Please sign in to comment.