FIXME: Changes to get share extension compiling

This was a slash and burn approach, and breaks existing functionality.
We need to address all of these before merging.

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent b56f0e0d25
commit 7894a58769

@ -90,7 +90,8 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 *
+ (void)checkPreKeysIfNecessary + (void)checkPreKeysIfNecessary
{ {
OWSAssert([UIApplication sharedApplication].applicationState == UIApplicationStateActive); // FIXME SHARINGEXTENSION
// OWSAssert([UIApplication sharedApplication].applicationState == UIApplicationStateActive);
// Update the prekey check timestamp. // Update the prekey check timestamp.
dispatch_async(TSPreKeyManager.prekeyQueue, ^{ dispatch_async(TSPreKeyManager.prekeyQueue, ^{

@ -14,7 +14,7 @@
#import "TSStorageManager.h" #import "TSStorageManager.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
// Can we move to Signal-iOS?
@interface OWSDisappearingMessagesJob () @interface OWSDisappearingMessagesJob ()
@property (nonatomic, readonly) YapDatabaseConnection *databaseConnection; @property (nonatomic, readonly) YapDatabaseConnection *databaseConnection;
@ -320,10 +320,12 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(date); OWSAssert(date);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
// Don't schedule run when inactive. // FIXME SHARINGEXTENSION
return; // if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
} // // Don't schedule run when inactive.
// return;
// }
NSDateFormatter *dateFormatter = [NSDateFormatter new]; NSDateFormatter *dateFormatter = [NSDateFormatter new];
dateFormatter.dateStyle = NSDateFormatterNoStyle; dateFormatter.dateStyle = NSDateFormatterNoStyle;
@ -364,11 +366,12 @@ NS_ASSUME_NONNULL_BEGIN
{ {
OWSAssert([NSThread isMainThread]); OWSAssert([NSThread isMainThread]);
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { // FIXME SHARINGEXTENSION
// Don't run when inactive. // if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
OWSFail(@"%@ Disappearing messages job timer fired while app inactive.", self.logTag); // // Don't run when inactive.
return; // OWSFail(@"%@ Disappearing messages job timer fired while app inactive.", self.logTag);
} // return;
// }
[self resetTimer]; [self resetTimer];

@ -443,12 +443,13 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
{ {
OWSAssert([NSThread isMainThread]); OWSAssert([NSThread isMainThread]);
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { // FIXME SHARINGEXTENSION
// Only try to sync if the app is active to avoid interfering with startup. // if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
// // // Only try to sync if the app is active to avoid interfering with startup.
// applicationDidBecomeActive: will try to sync again when the app becomes active. // //
return; // // applicationDidBecomeActive: will try to sync again when the app becomes active.
} // return;
// }
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@synchronized(self) @synchronized(self)

@ -1137,7 +1137,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateApplicationBadgeCount - (void)updateApplicationBadgeCount
{ {
NSUInteger numberOfItems = [self unreadMessagesCount]; NSUInteger numberOfItems = [self unreadMessagesCount];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:numberOfItems]; // FIXME SHARINGEXTENSION can't use UIApplication.sharedAplication
// [[UIApplication sharedApplication] setApplicationIconBadgeNumber:numberOfItems];
} }
- (NSUInteger)unreadMessagesInThread:(TSThread *)thread - (NSUInteger)unreadMessagesInThread:(TSThread *)thread

@ -225,15 +225,17 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4;
AssertIsOnMainThread(); AssertIsOnMainThread();
OWSAssert(self.backgroundTaskIdentifier == UIBackgroundTaskInvalid); OWSAssert(self.backgroundTaskIdentifier == UIBackgroundTaskInvalid);
self.backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ // FIXME SHARINGEXTENSION
DDLogWarn(@"%@ Timed out while in background trying to send message: %@", self.logTag, self.message); // self.backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[self endBackgroundTask]; // DDLogWarn(@"%@ Timed out while in background trying to send message: %@", self.logTag, self.message);
}]; // [self endBackgroundTask];
// }];
} }
- (void)endBackgroundTask - (void)endBackgroundTask
{ {
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskIdentifier]; // FIXME SHARINGEXTENSION
// [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskIdentifier];
} }
- (void)setBackgroundTaskIdentifier:(UIBackgroundTaskIdentifier)backgroundTaskIdentifier - (void)setBackgroundTaskIdentifier:(UIBackgroundTaskIdentifier)backgroundTaskIdentifier

@ -120,7 +120,9 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_
} }
self.hasObservedNotifications = YES; self.hasObservedNotifications = YES;
self.appIsActive = [UIApplication sharedApplication].applicationState == UIApplicationStateActive; // // FIXME SHARINGEXTENSION
// self.appIsActive = [UIApplication sharedApplication].applicationState == UIApplicationStateActive;
self.appIsActive = YES;
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidBecomeActive:) selector:@selector(applicationDidBecomeActive:)
@ -545,15 +547,16 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_
// Additionally, we want the reconnect timer to work in the background too. // Additionally, we want the reconnect timer to work in the background too.
[[NSRunLoop mainRunLoop] addTimer:self.backgroundKeepAliveTimer forMode:NSDefaultRunLoopMode]; [[NSRunLoop mainRunLoop] addTimer:self.backgroundKeepAliveTimer forMode:NSDefaultRunLoopMode];
self.fetchingTaskIdentifier = // FIXME SHARINGEXTENSION
[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ // self.fetchingTaskIdentifier =
OWSAssert([NSThread isMainThread]); // [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
// OWSAssert([NSThread isMainThread]);
DDLogInfo(@"%s background task expired", __PRETTY_FUNCTION__); //
// DDLogInfo(@"%s background task expired", __PRETTY_FUNCTION__);
[self clearBackgroundState]; //
[self applyDesiredSocketState]; // [self clearBackgroundState];
}]; // [self applyDesiredSocketState];
// }];
} else { } else {
OWSAssert(self.backgroundKeepAliveUntilDate); OWSAssert(self.backgroundKeepAliveUntilDate);
OWSAssert(self.backgroundKeepAliveTimer); OWSAssert(self.backgroundKeepAliveTimer);
@ -620,7 +623,8 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_
self.backgroundKeepAliveTimer = nil; self.backgroundKeepAliveTimer = nil;
if (self.fetchingTaskIdentifier != UIBackgroundTaskInvalid) { if (self.fetchingTaskIdentifier != UIBackgroundTaskInvalid) {
[[UIApplication sharedApplication] endBackgroundTask:self.fetchingTaskIdentifier]; // FIXME SHARINGEXTENSION
// [[UIApplication sharedApplication] endBackgroundTask:self.fetchingTaskIdentifier];
self.fetchingTaskIdentifier = UIBackgroundTaskInvalid; self.fetchingTaskIdentifier = UIBackgroundTaskInvalid;
} }
} }

@ -412,7 +412,8 @@ void setDatabaseInitialized()
- (void)backgroundedAppDatabasePasswordInaccessibleWithErrorDescription:(NSString *)errorDescription - (void)backgroundedAppDatabasePasswordInaccessibleWithErrorDescription:(NSString *)errorDescription
{ {
OWSAssert([UIApplication sharedApplication].applicationState == UIApplicationStateBackground); // FIXME SHARINGEXTENSION
// OWSAssert([UIApplication sharedApplication].applicationState == UIApplicationStateBackground);
// Sleep to give analytics events time to be delivered. // Sleep to give analytics events time to be delivered.
[NSThread sleepForTimeInterval:5.0f]; [NSThread sleepForTimeInterval:5.0f];
@ -433,17 +434,20 @@ void setDatabaseInitialized()
[SAMKeychain passwordForService:keychainService account:keychainDBPassAccount error:&keyFetchError]; [SAMKeychain passwordForService:keychainService account:keychainDBPassAccount error:&keyFetchError];
if (keyFetchError) { if (keyFetchError) {
UIApplicationState applicationState = [UIApplication sharedApplication].applicationState; // FIXME SHARINGEXTENSION
NSString *errorDescription = [NSString stringWithFormat:@"Database password inaccessible. No unlock since device restart? Error: %@ ApplicationState: %d", keyFetchError, (int)applicationState]; // UIApplicationState applicationState = [UIApplication sharedApplication].applicationState;
DDLogError(@"%@ %@", self.logTag, errorDescription); // NSString *errorDescription = [NSString stringWithFormat:@"Database password inaccessible. No unlock
[DDLog flushLog]; // since device restart? Error: %@ ApplicationState: %d", keyFetchError, (int)applicationState];
// DDLogError(@"%@ %@", self.logTag, errorDescription);
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { // [DDLog flushLog];
// TODO: Rather than crash here, we should detect the situation earlier
// and exit gracefully - (in the app delegate?). See the ` // FIXME SHARINGEXTENSION
// This is a last ditch effort to avoid blowing away the user's database. // if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
[self backgroundedAppDatabasePasswordInaccessibleWithErrorDescription:errorDescription]; // // TODO: Rather than crash here, we should detect the situation earlier
} // // and exit gracefully - (in the app delegate?). See the `
// // This is a last ditch effort to avoid blowing away the user's database.
// [self backgroundedAppDatabasePasswordInaccessibleWithErrorDescription:errorDescription];
// }
// At this point, either this is a new install so there's no existing password to retrieve // At this point, either this is a new install so there's no existing password to retrieve
// or the keychain has become corrupt. Either way, we want to get back to a // or the keychain has become corrupt. Either way, we want to get back to a
@ -455,9 +459,11 @@ void setDatabaseInitialized()
} }
// Try to reset app by deleting database. // Try to reset app by deleting database.
[self resetSignalStorage]; // FIXME SHARINGEXTENSION
OWSFail(@"disabled while Share extension is WIP");
// [self resetSignalStorage];
dbPassword = [self createAndSetNewDatabasePassword]; // dbPassword = [self createAndSetNewDatabasePassword];
} }
return [dbPassword dataUsingEncoding:NSUTF8StringEncoding]; return [dbPassword dataUsingEncoding:NSUTF8StringEncoding];

@ -231,11 +231,12 @@ NSString *NSStringForOWSAnalyticsSeverity(OWSAnalyticsSeverity severity)
DDLogDebug(@"%@ submitting: %@", self.logTag, eventKey); DDLogDebug(@"%@ submitting: %@", self.logTag, eventKey);
__block UIBackgroundTaskIdentifier task; __block UIBackgroundTaskIdentifier task;
task = [UIApplication.sharedApplication beginBackgroundTaskWithExpirationHandler:^{ // FIXME SHARINGEXTENSION can't use UIApplication.sharedAplication
failureBlock(); // task = [UIApplication.sharedApplication beginBackgroundTaskWithExpirationHandler:^{
// failureBlock();
[UIApplication.sharedApplication endBackgroundTask:task]; //
}]; // [UIApplication.sharedApplication endBackgroundTask:task];
// }];
// Until we integrate with an analytics platform, behave as though all event delivery succeeds. // Until we integrate with an analytics platform, behave as though all event delivery succeeds.
dispatch_async(self.serialQueue, ^{ dispatch_async(self.serialQueue, ^{
@ -245,8 +246,8 @@ NSString *NSStringForOWSAnalyticsSeverity(OWSAnalyticsSeverity severity)
} else { } else {
failureBlock(); failureBlock();
} }
// FIXME SHARINGEXTENSION can't use UIApplication.sharedAplication
[UIApplication.sharedApplication endBackgroundTask:task]; // [UIApplication.sharedApplication endBackgroundTask:task];
}); });
} }

Loading…
Cancel
Save