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
{
OWSAssert([UIApplication sharedApplication].applicationState == UIApplicationStateActive);
// FIXME SHARINGEXTENSION
// OWSAssert([UIApplication sharedApplication].applicationState == UIApplicationStateActive);
// Update the prekey check timestamp.
dispatch_async(TSPreKeyManager.prekeyQueue, ^{

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

@ -443,12 +443,13 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
{
OWSAssert([NSThread isMainThread]);
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;
}
// FIXME SHARINGEXTENSION
// 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;
// }
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@synchronized(self)

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

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

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

@ -412,7 +412,8 @@ void setDatabaseInitialized()
- (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.
[NSThread sleepForTimeInterval:5.0f];
@ -433,17 +434,20 @@ void setDatabaseInitialized()
[SAMKeychain passwordForService:keychainService account:keychainDBPassAccount error:&keyFetchError];
if (keyFetchError) {
UIApplicationState applicationState = [UIApplication sharedApplication].applicationState;
NSString *errorDescription = [NSString stringWithFormat:@"Database password inaccessible. No unlock since device restart? Error: %@ ApplicationState: %d", keyFetchError, (int)applicationState];
DDLogError(@"%@ %@", self.logTag, errorDescription);
[DDLog flushLog];
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
// 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];
}
// FIXME SHARINGEXTENSION
// UIApplicationState applicationState = [UIApplication sharedApplication].applicationState;
// NSString *errorDescription = [NSString stringWithFormat:@"Database password inaccessible. No unlock
// since device restart? Error: %@ ApplicationState: %d", keyFetchError, (int)applicationState];
// DDLogError(@"%@ %@", self.logTag, errorDescription);
// [DDLog flushLog];
// FIXME SHARINGEXTENSION
// if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
// // 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
// 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.
[self resetSignalStorage];
// FIXME SHARINGEXTENSION
OWSFail(@"disabled while Share extension is WIP");
// [self resetSignalStorage];
dbPassword = [self createAndSetNewDatabasePassword];
// dbPassword = [self createAndSetNewDatabasePassword];
}
return [dbPassword dataUsingEncoding:NSUTF8StringEncoding];

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

Loading…
Cancel
Save