Skip to content

Commit 3e3046b

Browse files
committed
Merge branch 'master' of github.com:WhisperSystems/TextSecure-iOS into verifyidentitykeys
2 parents 61631d1 + 2b6567d commit 3e3046b

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ One note, for programmers joining us from Java or similar language communities,
2121
###UI conventions
2222
We prefer to use [Storyboards](https://developer.apple.com/library/ios/documentation/general/conceptual/Devpedia-CocoaApp/Storyboard.html) vs. building UI elements within the code itself. We are not at the stage to provide a .strings localizable file for translating, but the goal is to have translatable strings in a single entry point so that we can reach users in their native language wherever possible.
2323

24+
Some tips
25+
- any PR that does not use segues or story board conventions (red flags: ```[self.navigationController pushViewController:<#(UIViewController *)#> animated:<#(BOOL)#>]``` and/or manual creation of UI elements and/or orphaned ViewControllers in the storyboard) will need to be refactored prior to merge
26+
- the following are the storyboarder's best friends:
27+
28+
```- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender;```
29+
30+
``` [self performSegueWithIdentifier:<#(NSString *)#> sender:<#(id)#>];```
31+
2432
## Tabs vs Spaces
2533

2634
It's the eternal debate. We chose to adopt spaces. Please set your default Xcode configuration to 4 spaces for tabs, and 4 spaces for indentation (it's Xcode's default setting).

TextSecureiOS/AppDelegate.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#import "TSWaitingPushMessageDatabase.h"
2323
#import "TSStorageMasterKey.h"
2424
#import "IASKSettingsReader.h"
25+
#import "TSSocketManager.h"
2526
#import "TSDeregisterAccountRequest.h"
2627
#define kChangePasswordAlertView 1
2728
#define kDeregisterAlertView 2
@@ -86,6 +87,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
8687
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePushesQueuedInDB) name:TSDatabaseDidUnlockNotification object:nil];
8788
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBasedOnUserSettings) name:kIASKAppSettingChanged object:nil];
8889

90+
[TSSocketManager becomeActive];
91+
8992
return YES;
9093
}
9194

@@ -143,6 +146,7 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto
143146
}
144147
}
145148
- (void)applicationDidEnterBackground:(UIApplication *)application {
149+
[TSSocketManager resignActivity];
146150
if ([[NSUserDefaults standardUserDefaults] boolForKey:kScreenshotProtection]) {
147151
self.blankWindow.hidden = NO;
148152
}
@@ -151,6 +155,7 @@ - (void)applicationDidEnterBackground:(UIApplication *)application {
151155
- (void)applicationWillEnterForeground:(UIApplication *)application {
152156
self.blankWindow.hidden = YES;
153157
[self updateBasedOnUserSettings];
158+
[TSSocketManager becomeActive];
154159
}
155160

156161

TextSecureiOS/Networking/TSNetworkManager.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ + (id)sharedManager {
3131
- (id)init {
3232
if (self = [super init]) {
3333
operationManager = [[AFHTTPRequestOperationManager manager] initWithBaseURL:[[NSURL alloc] initWithString:textSecureServer]];
34-
operationManager.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey];
34+
#warning use pinning with : AFSSLPinningModePublicKey
35+
operationManager.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
3536
operationManager.securityPolicy.allowInvalidCertificates = YES; // We are not signed by a valid certification authority.
3637
operationManager.requestSerializer = [AFJSONRequestSerializer serializer];
3738
}

TextSecureiOS/Networking/TSSocketManager.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ - (id)init{
1919
self = [super init];
2020

2121
if (self) {
22-
// TO-DO <===
23-
NSString *webSocketConnect = [NSString stringWithFormat:@"%@", textSecureWebSocketAPI];
22+
NSString *webSocketConnect = [NSString stringWithFormat:@"%@?user=%@&password=%@", textSecureWebSocketAPI, [[TSKeyManager getUsernameToken] stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"],[TSKeyManager getAuthenticationToken]];
2423
NSURL *webSocketConnectURL = [NSURL URLWithString:webSocketConnect];
24+
NSLog(@"WebsocketURL %@", webSocketConnectURL);
2525
self.websocket = [[SRWebSocket alloc] initWithURL:webSocketConnectURL];
26+
self.websocket.delegate = self;
2627
}
2728

2829
return self;
@@ -40,25 +41,26 @@ + (id)sharedManager {
4041
#pragma mark - Manage Socket
4142

4243
+ (void)becomeActive{
43-
44+
DLog(@"Socket resuming activity");
45+
[[[self sharedManager] websocket] open];
4446
}
4547

4648
+ (void)resignActivity{
47-
49+
DLog(@"Socket resigning activity");
4850
}
4951

5052
#pragma mark - Delegate methods
5153

5254
- (void) webSocketDidOpen:(SRWebSocket *)webSocket{
53-
55+
NSLog(@"WebSocket was sucessfully opened");
5456
}
5557

5658
- (void) webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message{
5759

5860
}
5961

6062
- (void) webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error{
61-
63+
DLog(@"Error connecting to socket %@", error);
6264
}
6365

6466
- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean{

TextSecureiOS/Utility/Constants.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#warning Staging environement used. Production: https://textsecure-service.whispersystems.org
2020

21-
NSString* const textSecureWebSocketAPI = @"wws://textsecure-service-staging.whispersystems.org/";
21+
NSString* const textSecureWebSocketAPI = @"wss://textsecure-service-staging.whispersystems.org/v1/websocket/";
2222
NSString* const textSecureServer = @"https://textsecure-service-staging.whispersystems.org/";
2323

2424
NSString* const textSecureGeneralAPI = @"v1";

0 commit comments

Comments
 (0)