Addressing issues with background decryption.

- Simplifying background timeout strategy for reliabilty.
- Adding Notifications settings.
- Dropping support for VOIP Push < 8.2 because buggy.
pull/1/head
Frederic Jacobs 10 years ago
parent 2d41a3e25e
commit 1550c61216

@ -2,18 +2,14 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>NSContactsUsageDescription</key>
<string>Signal uses your AddressBook as contacts list. We do not store your contacts on the server.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Signal needs access to your microphone to make and receive phone calls.</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string> <string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string> <string>${EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIcons</key> <key>CFBundleIcons</key>
<dict/> <dict/>
<key>CFBundleIcons~ipad</key> <key>CFBundleIcons~ipad</key>
@ -44,7 +40,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2.0.21</string> <string>2.0.22</string>
<key>LOGS_EMAIL</key> <key>LOGS_EMAIL</key>
<string>support@whispersystems.org</string> <string>support@whispersystems.org</string>
<key>LOGS_URL</key> <key>LOGS_URL</key>
@ -53,6 +49,10 @@
<string>public.app-category.social-networking</string> <string>public.app-category.social-networking</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSContactsUsageDescription</key>
<string>Signal uses your AddressBook as contacts list. We do not store your contacts on the server.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Signal needs access to your microphone to make and receive phone calls.</string>
<key>UIAppFonts</key> <key>UIAppFonts</key>
<array> <array>
<string>HelveticaNeueLTStd-Bd.otf</string> <string>HelveticaNeueLTStd-Bd.otf</string>

@ -60,10 +60,10 @@
// the phone directory being looked up during tests. // the phone directory being looked up during tests.
loggingIsEnabled = TRUE; loggingIsEnabled = TRUE;
[DebugLogger.sharedInstance enableTTYLogging]; [DebugLogger.sharedInstance enableTTYLogging];
#elif RELEASE #elif RELEASE
loggingIsEnabled = Environment.preferences.loggingIsEnabled; loggingIsEnabled = Environment.preferences.loggingIsEnabled;
#endif #endif
[self verifyBackgroundBeforeKeysAvailableLaunch];
if (loggingIsEnabled) { if (loggingIsEnabled) {
[DebugLogger.sharedInstance enableFileLogging]; [DebugLogger.sharedInstance enableFileLogging];
@ -260,6 +260,22 @@
[[PushManager sharedManager] application:application handleActionWithIdentifier:identifier forLocalNotification:notification completionHandler:completionHandler]; [[PushManager sharedManager] application:application handleActionWithIdentifier:identifier forLocalNotification:notification completionHandler:completionHandler];
} }
/**
* Signal requires an iPhone to be unlocked after reboot to be able to access keying material.
*/
- (void)verifyBackgroundBeforeKeysAvailableLaunch {
if ([self applicationIsActive]) {
return;
}
if (![[TSStorageManager sharedManager] databasePasswordAccessible]) {
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = NSLocalizedString(@"PHONE_NEEDS_UNLOCK", nil);
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
exit(0);
}
}
- (BOOL)applicationIsActive { - (BOOL)applicationIsActive {
UIApplication *app = [UIApplication sharedApplication]; UIApplication *app = [UIApplication sharedApplication];

@ -242,7 +242,7 @@
<constraint firstAttribute="width" constant="250" id="siA-1a-pO1"/> <constraint firstAttribute="width" constant="250" id="siA-1a-pO1"/>
</constraints> </constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
@ -1129,7 +1129,7 @@ A0 09 9A FF A8 8A 09 99</string>
<constraint firstAttribute="width" constant="126" id="IoY-EK-Qhk"/> <constraint firstAttribute="width" constant="126" id="IoY-EK-Qhk"/>
</constraints> </constraints>
<fontDescription key="fontDescription" name="HelveticaNeue-Thin" family="Helvetica Neue" pointSize="17"/> <fontDescription key="fontDescription" name="HelveticaNeue-Thin" family="Helvetica Neue" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
@ -2138,7 +2138,7 @@ A0 09 9A FF A8 8A 09 99</string>
<constraint firstAttribute="width" constant="244" id="Y66-3d-yJI"/> <constraint firstAttribute="width" constant="244" id="Y66-3d-yJI"/>
</constraints> </constraints>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="19"/> <fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="19"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
@ -3777,7 +3777,7 @@ A0 09 9A FF A8 8A 09 99</string>
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="FhQ-dM-1mj"> <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="FhQ-dM-1mj">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/> <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/> <color key="backgroundColor" red="0.93725490196078431" green="0.93725490196078431" blue="0.95686274509803926" alpha="1" colorSpace="calibratedRGB"/>
<view key="tableFooterView" contentMode="scaleToFill" id="Ezq-Cw-na2"> <view key="tableFooterView" contentMode="scaleToFill" id="Ezq-Cw-na2">
<rect key="frame" x="0.0" y="600" width="600" height="568"/> <rect key="frame" x="0.0" y="600" width="600" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@ -3818,7 +3818,7 @@ A0 09 9A FF A8 8A 09 99</string>
<constraint firstAttribute="height" constant="29" id="Qtv-Rd-0jb"/> <constraint firstAttribute="height" constant="29" id="Qtv-Rd-0jb"/>
</constraints> </constraints>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="22"/> <fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="22"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
@ -3983,7 +3983,7 @@ A0 09 9A FF A8 8A 09 99</string>
</constraint> </constraint>
</constraints> </constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
@ -4110,7 +4110,7 @@ A0 09 9A FF A8 8A 09 99</string>
</constraint> </constraint>
</constraints> </constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
@ -4173,7 +4173,7 @@ A0 09 9A FF A8 8A 09 99</string>
</constraint> </constraint>
</constraints> </constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
@ -4204,10 +4204,10 @@ A0 09 9A FF A8 8A 09 99</string>
<exclude reference="BaC-fn-VoA"/> <exclude reference="BaC-fn-VoA"/>
</mask> </mask>
<mask key="constraints"> <mask key="constraints">
<exclude reference="gMd-UT-AWs"/> <exclude reference="Tae-ZO-Fxf"/>
<exclude reference="U1d-NR-s31"/> <exclude reference="U1d-NR-s31"/>
<exclude reference="gMd-UT-AWs"/>
<exclude reference="zfO-kb-UBa"/> <exclude reference="zfO-kb-UBa"/>
<exclude reference="Tae-ZO-Fxf"/>
</mask> </mask>
</variation> </variation>
<variation key="heightClass=regular-widthClass=compact"> <variation key="heightClass=regular-widthClass=compact">
@ -4215,10 +4215,10 @@ A0 09 9A FF A8 8A 09 99</string>
<include reference="BaC-fn-VoA"/> <include reference="BaC-fn-VoA"/>
</mask> </mask>
<mask key="constraints"> <mask key="constraints">
<include reference="gMd-UT-AWs"/> <include reference="Tae-ZO-Fxf"/>
<exclude reference="U1d-NR-s31"/> <exclude reference="U1d-NR-s31"/>
<include reference="gMd-UT-AWs"/>
<exclude reference="zfO-kb-UBa"/> <exclude reference="zfO-kb-UBa"/>
<include reference="Tae-ZO-Fxf"/>
</mask> </mask>
</variation> </variation>
</tableViewCellContentView> </tableViewCellContentView>
@ -4236,7 +4236,7 @@ A0 09 9A FF A8 8A 09 99</string>
</constraint> </constraint>
</constraints> </constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
@ -4299,7 +4299,7 @@ A0 09 9A FF A8 8A 09 99</string>
</constraint> </constraint>
</constraints> </constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
@ -4518,7 +4518,7 @@ A0 09 9A FF A8 8A 09 99</string>
</constraint> </constraint>
</constraints> </constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
@ -4798,9 +4798,6 @@ A0 09 9A FF A8 8A 09 99</string>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/> <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> <color key="textColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="heightClass=regular-widthClass=compact" misplaced="YES">
<rect key="frame" x="10" y="274" width="130" height="21"/>
</variation>
</label> </label>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@ -4848,7 +4845,7 @@ A0 09 9A FF A8 8A 09 99</string>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="a4j-OQ-ala"> <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="a4j-OQ-ala">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="20"/> <fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
<variation key="heightClass=regular-widthClass=compact"> <variation key="heightClass=regular-widthClass=compact">
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="18"/> <fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="18"/>

@ -44,6 +44,9 @@ typedef NS_ENUM(NSUInteger, TSImageQuality) {
- (BOOL)soundInForeground; - (BOOL)soundInForeground;
- (void)setSoundInForeground:(BOOL)enabled; - (void)setSoundInForeground:(BOOL)enabled;
- (BOOL)hasRegisteredVOIPPush;
-(void)setHasRegisteredVOIPPush:(BOOL)enabled;
- (TSImageQuality)imageUploadQuality; - (TSImageQuality)imageUploadQuality;
- (void)setImageUploadQuality:(TSImageQuality)quality; - (void)setImageUploadQuality:(TSImageQuality)quality;

@ -28,6 +28,7 @@
#define HAS_ARCHIVED_A_MESSAGE_KEY @"User archived a message" #define HAS_ARCHIVED_A_MESSAGE_KEY @"User archived a message"
#define kSignalVersionKey @"SignalUpdateVersionKey" #define kSignalVersionKey @"SignalUpdateVersionKey"
#define PLAY_SOUND_IN_FOREGROUND_KEY @"NotificationSoundInForeground" #define PLAY_SOUND_IN_FOREGROUND_KEY @"NotificationSoundInForeground"
#define HAS_REGISTERED_VOIP_PUSH @"VOIPPushEnabled"
#define BloomFilterCacheName @"bloomfilter" #define BloomFilterCacheName @"bloomfilter"
@ -142,6 +143,16 @@
} }
- (BOOL)hasRegisteredVOIPPush {
NSNumber *preference = [self tryGetValueForKey:HAS_REGISTERED_VOIP_PUSH];
if (preference) {
return [preference boolValue];
} else{
return YES;
}
}
-(TSImageQuality)imageUploadQuality { -(TSImageQuality)imageUploadQuality {
// always return average image quality // always return average image quality
return TSImageQualityMedium; return TSImageQualityMedium;
@ -159,6 +170,10 @@
[self setValueForKey:FRESH_INSTALL_TUTORIALS_ENABLED_KEY toValue:@(enabled)]; [self setValueForKey:FRESH_INSTALL_TUTORIALS_ENABLED_KEY toValue:@(enabled)];
} }
-(void)setHasRegisteredVOIPPush:(BOOL)enabled {
[self setValueForKey:HAS_REGISTERED_VOIP_PUSH toValue:@(enabled)];
}
-(void) setContactImagesEnabled:(BOOL)enabled { -(void) setContactImagesEnabled:(BOOL)enabled {
[self setValueForKey:CONTACT_IMAGES_ENABLED_KEY toValue:@(enabled)]; [self setValueForKey:CONTACT_IMAGES_ENABLED_KEY toValue:@(enabled)];
} }

@ -40,7 +40,8 @@
NSString *currentVersion = [Environment.preferences setAndGetCurrentVersion]; NSString *currentVersion = [Environment.preferences setAndGetCurrentVersion];
BOOL isCurrentlyMigrating = [VersionMigrations isMigratingTo2Dot0]; BOOL isCurrentlyMigrating = [VersionMigrations isMigratingTo2Dot0];
BOOL needsToRegisterPush = [VersionMigrations needsRegisterPush]; BOOL needsToRegisterPush = [VersionMigrations needsRegisterPush];
BOOL VOIPRegistration = [[PushManager sharedManager] supportsVOIPPush]
&& ![Environment.preferences hasRegisteredVOIPPush];
if (!previousVersion) { if (!previousVersion) {
DDLogError(@"No previous version found. Possibly first launch since install."); DDLogError(@"No previous version found. Possibly first launch since install.");
return; return;
@ -58,6 +59,20 @@
[self clearVideoCache]; [self clearVideoCache];
[self blockingPushRegistration]; [self blockingPushRegistration];
} }
if (VOIPRegistration) {
[PushManager.sharedManager registrationAndRedPhoneTokenRequestWithSuccess:^(NSData *pushToken, NSData *voipToken, NSString *signupToken) {
[TSAccountManager registerWithRedPhoneToken:signupToken
pushToken:pushToken
voipToken:voipToken
success:^{[Environment.preferences setHasRegisteredVOIPPush:YES];}
failure:^(NSError *error) {
DDLogError(@"Couldn't register with TextSecure server: %@", error.debugDescription);
}];
} failure:^(NSError *error) {
DDLogError(@"Couldn't register with RedPhone server.");
}];
}
} }
+ (BOOL)isMigrating{ + (BOOL)isMigrating{
@ -243,6 +258,7 @@
[[PushManager sharedManager] requestPushTokenWithSuccess:^(NSData *pushToken, NSData *voipToken) { [[PushManager sharedManager] requestPushTokenWithSuccess:^(NSData *pushToken, NSData *voipToken) {
[TSAccountManager registerForPushNotifications:pushToken voipToken:voipToken success:^{ [TSAccountManager registerForPushNotifications:pushToken voipToken:voipToken success:^{
[[NSUserDefaults standardUserDefaults] removeObjectForKey:NEEDS_TO_REGISTER_PUSH_KEY]; [[NSUserDefaults standardUserDefaults] removeObjectForKey:NEEDS_TO_REGISTER_PUSH_KEY];
[waitingController dismissViewControllerAnimated:YES completion:nil];
} failure:failure]; } failure:failure];
} failure:failure]; } failure:failure];
} }

@ -85,6 +85,14 @@
#endif #endif
#ifndef NSFoundationVersionNumber_iOS_8_2_0
#define NSFoundationVersionNumber_iOS_8_2_0 1142 //extracted with NSLog(@"%f", NSFoundationVersionNumber)
#endif
#ifdef NSFoundationVersionNumber_iOS_8_2_0
#define _iOS_8_2_0 NSFoundationVersionNumber_iOS_8_2_0
#endif
/** /**
Add a Singelton implementation to the .m File Add a Singelton implementation to the .m File
*/ */

@ -65,6 +65,7 @@ typedef void (^registrationTokensSuccessBlock)(NSData *pushToken, NSData *voipTo
@property TOCFutureSource *pushKitNotificationFutureSource; @property TOCFutureSource *pushKitNotificationFutureSource;
-(TOCFuture*)registerPushKitNotificationFuture; -(TOCFuture*)registerPushKitNotificationFuture;
- (BOOL)supportsVOIPPush;
#pragma mark Push Notifications Delegate Methods #pragma mark Push Notifications Delegate Methods

@ -168,7 +168,7 @@
#pragma mark PushKit #pragma mark PushKit
-(void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type - (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type
{ {
[[PushManager sharedManager].pushKitNotificationFutureSource trySetResult:credentials.token]; [[PushManager sharedManager].pushKitNotificationFutureSource trySetResult:credentials.token];
} }
@ -178,12 +178,27 @@
[self application:[UIApplication sharedApplication] didReceiveRemoteNotification:payload.dictionaryPayload]; [self application:[UIApplication sharedApplication] didReceiveRemoteNotification:payload.dictionaryPayload];
} }
-(TOCFuture*)registerPushKitNotificationFuture{ - (TOCFuture*)registerPushKitNotificationFuture{
self.pushKitNotificationFutureSource = [TOCFutureSource new]; if ([self supportsVOIPPush]) {
PKPushRegistry* voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()]; self.pushKitNotificationFutureSource = [TOCFutureSource new];
voipRegistry.delegate = self; PKPushRegistry* voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; voipRegistry.delegate = self;
return self.pushKitNotificationFutureSource.future; voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
return self.pushKitNotificationFutureSource.future;
} else {
TOCFutureSource *futureSource = [TOCFutureSource new];
[futureSource trySetResult:nil];
[Environment.preferences setHasRegisteredVOIPPush:FALSE];
return futureSource.future;
}
}
- (BOOL)supportsVOIPPush {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(_iOS_8_2_0)) {
return YES;
} else {
return NO;
}
} }
#pragma mark Register device for Push Notification locally #pragma mark Register device for Push Notification locally
@ -287,24 +302,17 @@
} }
- (UIUserNotificationCategory*)userNotificationsMessageCategory{ - (UIUserNotificationCategory*)userNotificationsMessageCategory{
UIMutableUserNotificationAction *action_accept = [UIMutableUserNotificationAction new]; UIMutableUserNotificationAction *action_view = [UIMutableUserNotificationAction new];
action_accept.identifier = Signal_Message_View_Identifier; action_view.identifier = Signal_Message_View_Identifier;
action_accept.title = NSLocalizedString(@"View", @""); action_view.title = NSLocalizedString(@"View", @"");
action_accept.activationMode = UIUserNotificationActivationModeForeground; action_view.activationMode = UIUserNotificationActivationModeForeground;
action_accept.destructive = NO; action_view.destructive = NO;
action_accept.authenticationRequired = YES; action_view.authenticationRequired = YES;
UIMutableUserNotificationAction *action_decline = [UIMutableUserNotificationAction new];
action_decline.identifier = Signal_Message_MarkAsRead_Identifier;
action_decline.title = NSLocalizedString(@"Mark as read", @"");
action_decline.activationMode = UIUserNotificationActivationModeBackground;
action_decline.destructive = NO;
action_decline.authenticationRequired = NO;
UIMutableUserNotificationCategory *messageCategory = [UIMutableUserNotificationCategory new]; UIMutableUserNotificationCategory *messageCategory = [UIMutableUserNotificationCategory new];
messageCategory.identifier = Signal_Message_Category; messageCategory.identifier = Signal_Message_Category;
[messageCategory setActions:@[action_accept, action_decline] forContext:UIUserNotificationActionContextMinimal]; [messageCategory setActions:@[action_view] forContext:UIUserNotificationActionContextMinimal];
[messageCategory setActions:@[action_accept, action_decline] forContext:UIUserNotificationActionContextDefault]; [messageCategory setActions:@[action_view] forContext:UIUserNotificationActionContextDefault];
return messageCategory; return messageCategory;
} }

@ -410,7 +410,9 @@
} }
- (void)notifyUserForIncomingMessage:(TSIncomingMessage*)message from:(NSString*)name inThread:(TSThread*)thread { - (void)notifyUserForIncomingMessage:(TSIncomingMessage*)message from:(NSString*)name inThread:(TSThread*)thread {
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { NSString *messageDescription = message.description;
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && messageDescription) {
UILocalNotification *notification = [[UILocalNotification alloc] init]; UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.category = Signal_Message_Category; notification.category = Signal_Message_Category;
notification.userInfo = @{Signal_Thread_UserInfo_Key:thread.uniqueId}; notification.userInfo = @{Signal_Thread_UserInfo_Key:thread.uniqueId};
@ -423,9 +425,9 @@
sender = message.authorId; sender = message.authorId;
} }
notification.alertBody = [NSString stringWithFormat:@"New message from %@ in group \"%@\": %@", sender, name, message.description]; notification.alertBody = [NSString stringWithFormat:@"New message from %@ in group \"%@\": %@", sender, name, messageDescription];
} else { } else {
notification.alertBody = [NSString stringWithFormat:@"%@: %@", name, message.description]; notification.alertBody = [NSString stringWithFormat:@"%@: %@", name, messageDescription];
} }
break; break;
case NotificationNameNoPreview:{ case NotificationNameNoPreview:{

@ -18,7 +18,11 @@
self.HTTPMethod = @"PUT"; self.HTTPMethod = @"PUT";
self.parameters = [NSMutableDictionary dictionaryWithObjects:@[identifier, voipId] forKeys:@[@"apnRegistrationId", @"voipRegistrationId"]]; self.parameters = [@{@"apnRegistrationId":identifier} mutableCopy];
if (voipId) {
[self.parameters setObject:voipId forKeyedSubscript:@"voipRegistrationId"];
}
return self; return self;
} }

@ -37,6 +37,8 @@ NSString * const SocketConnectingNotification = @"SocketConnectingNotification";
@property (nonatomic, retain) NSTimer *backgroundConnectTimer; @property (nonatomic, retain) NSTimer *backgroundConnectTimer;
@property (nonatomic) UIBackgroundTaskIdentifier fetchingTaskIdentifier; @property (nonatomic) UIBackgroundTaskIdentifier fetchingTaskIdentifier;
@property BOOL didFetchInBackground;
@end @end
@implementation TSSocketManager @implementation TSSocketManager
@ -131,6 +133,7 @@ NSString * const SocketConnectingNotification = @"SocketConnectingNotification";
- (void) webSocket:(SRWebSocket *)webSocket didReceiveMessage:(NSData*)data { - (void) webSocket:(SRWebSocket *)webSocket didReceiveMessage:(NSData*)data {
WebSocketMessage *wsMessage = [WebSocketMessage parseFromData:data]; WebSocketMessage *wsMessage = [WebSocketMessage parseFromData:data];
self.didFetchInBackground = YES;
if (wsMessage.type == WebSocketMessageTypeRequest) { if (wsMessage.type == WebSocketMessageTypeRequest) {
[self processWebSocketRequestMessage:wsMessage.request]; [self processWebSocketRequestMessage:wsMessage.request];
@ -232,42 +235,30 @@ NSString * const SocketConnectingNotification = @"SocketConnectingNotification";
TSSocketManager *sharedInstance = [TSSocketManager sharedManager]; TSSocketManager *sharedInstance = [TSSocketManager sharedManager];
if (sharedInstance.fetchingTaskIdentifier == 0) { if (sharedInstance.fetchingTaskIdentifier == 0) {
sharedInstance.didFetchInBackground = NO;
sharedInstance.fetchingTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ sharedInstance.fetchingTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
if (!sharedInstance.didFetchInBackground) {
[sharedInstance backgroundConnectTimedOut];
}
sharedInstance.fetchingTaskIdentifier = 0; sharedInstance.fetchingTaskIdentifier = 0;
[TSSocketManager resignActivity]; [TSSocketManager resignActivity];
}]; }];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSTimer * timer = [NSTimer timerWithTimeInterval:kBackgroundConnectTimer
target:sharedInstance
selector:@selector(closeBackgroundTask)
userInfo:nil
repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:timer
forMode:NSDefaultRunLoopMode];
});
[self becomeActive]; [self becomeActive];
} }
} }
- (void)closeBackgroundTask { - (void)closeBackgroundTask {
UIBackgroundTaskIdentifier identifier = self.fetchingTaskIdentifier; UIBackgroundTaskIdentifier identifier = self.fetchingTaskIdentifier;
self.fetchingTaskIdentifier = 0; self.fetchingTaskIdentifier = 0;
if ([_websocket readyState] != SR_OPEN) {
[self backgroundConnectTimedOut];
}
[TSSocketManager resignActivity]; [TSSocketManager resignActivity];
[[UIApplication sharedApplication] endBackgroundTask:identifier]; [[UIApplication sharedApplication] endBackgroundTask:identifier];
} }
- (void)backgroundConnectTimedOut { - (void)backgroundConnectTimedOut {
UILocalNotification *notification = [[UILocalNotification alloc] init]; UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = NSLocalizedString(@"APN_FETCHED_FAILED", nil); notification.alertBody = NSLocalizedString(@"APN_FETCHED_FAILED", nil);
[[UIApplication sharedApplication] presentLocalNotificationNow:notification]; [[UIApplication sharedApplication] presentLocalNotificationNow:notification];
} }

@ -22,6 +22,7 @@ extern NSString *const TSUIDatabaseConnectionDidUpdateNotification;
+ (instancetype)sharedManager; + (instancetype)sharedManager;
- (void)setupDatabase; - (void)setupDatabase;
- (void)deleteThreadsAndMessages; - (void)deleteThreadsAndMessages;
- (BOOL)databasePasswordAccessible;
- (void)wipeSignalStorage; - (void)wipeSignalStorage;
- (YapDatabase*)database; - (YapDatabase*)database;

@ -146,6 +146,22 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass";
return databasePath; return databasePath;
} }
- (BOOL)databasePasswordAccessible {
[SSKeychain setAccessibilityType:kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly];
NSError *error;
NSString *dbPassword = [SSKeychain passwordForService:keychainService account:keychainDBPassAccount error:&error];
if (dbPassword && !error) {
return YES;
}
if (error) {
DDLogWarn(@"Database password couldn't be accessed: %@", error.localizedDescription);
}
return NO;
}
- (NSData*)databasePassword { - (NSData*)databasePassword {
[SSKeychain setAccessibilityType:kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly]; [SSKeychain setAccessibilityType:kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly];
NSString *dbPassword = [SSKeychain passwordForService:keychainService account:keychainDBPassAccount]; NSString *dbPassword = [SSKeychain passwordForService:keychainService account:keychainDBPassAccount];

@ -10,14 +10,18 @@
#import <PastelogKit/Pastelog.h> #import <PastelogKit/Pastelog.h>
#import "Environment.h" #import "Environment.h"
#import "PreferencesUtil.h"
#import "DebugLogger.h" #import "DebugLogger.h"
#import "TSAccountManager.h"
#import "PreferencesUtil.h"
#import "PushManager.h"
@interface AdvancedSettingsTableViewController () @interface AdvancedSettingsTableViewController ()
@property (strong, nonatomic) UITableViewCell * enableLogCell; @property NSArray *sectionsArray;
@property (strong, nonatomic) UITableViewCell * submitLogCell; @property (strong, nonatomic) UITableViewCell *enableLogCell;
@property (strong, nonatomic) UITableViewCell *submitLogCell;
@property (strong, nonatomic) UITableViewCell *registerPushCell;
@property (strong, nonatomic) UISwitch * enableLogSwitch; @property (strong, nonatomic) UISwitch * enableLogSwitch;
@end @end
@ -31,6 +35,9 @@
} }
-(instancetype)init { -(instancetype)init {
self.sectionsArray = @[NSLocalizedString(@"LOGGING_SECTION", nil),
NSLocalizedString(@"PUSH_REGISTER_TITLE", nil)];
return [super initWithStyle:UITableViewStyleGrouped]; return [super initWithStyle:UITableViewStyleGrouped];
} }
@ -55,32 +62,45 @@
self.enableLogCell.accessoryView = self.enableLogSwitch; self.enableLogCell.accessoryView = self.enableLogSwitch;
//Send Log //Send Log
self.submitLogCell = [[UITableViewCell alloc]init]; self.submitLogCell = [[UITableViewCell alloc]init];
self.submitLogCell.textLabel.text = NSLocalizedString(@"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG", @""); self.submitLogCell.textLabel.text = NSLocalizedString(@"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG", @"");
self.registerPushCell = [[UITableViewCell alloc] init];
self.registerPushCell.textLabel.text = NSLocalizedString(@"REREGISTER_FOR_PUSH", nil);
} }
#pragma mark - Table view data source #pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1; return (NSInteger)[self.sectionsArray count];
} }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.enableLogSwitch.isOn ? 2 : 1; switch (section) {
case 0:
return self.enableLogSwitch.isOn ? 2 : 1;
case 1:
return 1;
default:
return 0;
}
} }
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{ {
return @"Logging"; return [self.sectionsArray objectAtIndex:(NSUInteger)section];
} }
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
switch (indexPath.row) { if (indexPath.section == 0) {
case 0: return self.enableLogCell; switch (indexPath.row) {
case 1: return self.submitLogCell; case 0: return self.enableLogCell;
case 1: return self.enableLogSwitch.isOn ? self.submitLogCell:self.registerPushCell;
}
} else {
return self.registerPushCell;
} }
NSAssert(false, @"No Cell configured"); NSAssert(false, @"No Cell configured");
@ -92,10 +112,23 @@
{ {
[tableView deselectRowAtIndexPath:indexPath animated:YES]; [tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row == 1) if ([tableView cellForRowAtIndexPath:indexPath] == self.submitLogCell)
{ {
[Pastelog submitLogs]; [Pastelog submitLogs];
} else if ([tableView cellForRowAtIndexPath:indexPath] == self.registerPushCell) {
__block failedPushRegistrationBlock failure = ^(NSError *error) {
SignalAlertView(NSLocalizedString(@"PUSH_REGISTER_TITLE", nil),
NSLocalizedString(@"REGISTRATION_BODY", nil));
};
[[PushManager sharedManager] requestPushTokenWithSuccess:^(NSData *pushToken, NSData *voipToken) {
[TSAccountManager registerForPushNotifications:pushToken voipToken:voipToken success:^{
SignalAlertView(NSLocalizedString(@"PUSH_REGISTER_TITLE", nil),
NSLocalizedString(@"PUSH_REGISTER_SUCCESS", nil));
} failure:failure];
} failure:failure];
} }
} }
#pragma mark - Actions #pragma mark - Actions

Loading…
Cancel
Save