mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-20 19:19:52 +00:00
Fixed “ivar is being directly accessed” warnings. Part 1
This commit is contained in:
@@ -27,9 +27,13 @@ static NSInteger const BITDebugBatchInterval = 3;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation BITChannel {
|
||||
id _appDidEnterBackgroundObserver;
|
||||
}
|
||||
@interface BITChannel ()
|
||||
|
||||
@property (nonatomic, weak, nullable) id appDidEnterBackgroundObserver;
|
||||
|
||||
@end
|
||||
|
||||
@implementation BITChannel
|
||||
|
||||
@synthesize persistence = _persistence;
|
||||
@synthesize channelBlocked = _channelBlocked;
|
||||
@@ -72,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void) registerObservers {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
if(nil == _appDidEnterBackgroundObserver) {
|
||||
if(nil == self.appDidEnterBackgroundObserver) {
|
||||
void (^notificationBlock)(NSNotification *note) = ^(NSNotification *note) {
|
||||
typeof(self) strongSelf = weakSelf;
|
||||
if ([strongSelf timerIsRunning]) {
|
||||
@@ -91,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
}];
|
||||
}
|
||||
};
|
||||
_appDidEnterBackgroundObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification
|
||||
self.appDidEnterBackgroundObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification
|
||||
object:nil
|
||||
queue:NSOperationQueue.mainQueue
|
||||
usingBlock:notificationBlock];
|
||||
@@ -99,9 +103,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
}
|
||||
|
||||
- (void) unregisterObservers {
|
||||
if(_appDidEnterBackgroundObserver) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:_appDidEnterBackgroundObserver];
|
||||
_appDidEnterBackgroundObserver = nil;
|
||||
if(self.appDidEnterBackgroundObserver) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self.appDidEnterBackgroundObserver];
|
||||
self.appDidEnterBackgroundObserver = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)resetQueue {
|
||||
bit_resetSafeJsonStream(&BITSafeJsonEventsString);
|
||||
_dataItemCount = 0;
|
||||
self.dataItemCount = 0;
|
||||
}
|
||||
|
||||
#pragma mark - Adding to queue
|
||||
@@ -163,11 +167,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
NSDictionary *dict = [self dictionaryForTelemetryData:item];
|
||||
[strongSelf appendDictionaryToJsonStream:dict];
|
||||
|
||||
if (strongSelf->_dataItemCount >= self.maxBatchSize) {
|
||||
if (strongSelf.dataItemCount >= self.maxBatchSize) {
|
||||
// Case 3: Max batch count has been reached, so write queue to disk and delete all items.
|
||||
[strongSelf persistDataItemQueue];
|
||||
|
||||
} else if (strongSelf->_dataItemCount == 1) {
|
||||
} else if (strongSelf.dataItemCount == 1) {
|
||||
// Case 4: It is the first item, let's start the timer.
|
||||
if (![strongSelf timerIsRunning]) {
|
||||
[strongSelf startTimer];
|
||||
@@ -194,9 +198,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
BITEnvelope *envelope = [BITEnvelope new];
|
||||
envelope.time = bit_utcDateString([NSDate date]);
|
||||
envelope.iKey = _telemetryContext.appIdentifier;
|
||||
envelope.iKey = self.telemetryContext.appIdentifier;
|
||||
|
||||
envelope.tags = _telemetryContext.contextDictionary;
|
||||
envelope.tags = self.telemetryContext.contextDictionary;
|
||||
envelope.data = data;
|
||||
envelope.name = telemetryData.envelopeTypeName;
|
||||
|
||||
@@ -225,7 +229,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// Since we can't persist every event right away, we write it to a simple C string.
|
||||
// This can then be written to disk by a signal handler in case of a crash.
|
||||
bit_appendStringToSafeJsonStream(string, &(BITSafeJsonEventsString));
|
||||
_dataItemCount += 1;
|
||||
self.dataItemCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +291,7 @@ void bit_resetSafeJsonStream(char **string) {
|
||||
typeof(self) strongSelf = weakSelf;
|
||||
|
||||
if(strongSelf) {
|
||||
if (strongSelf->_dataItemCount > 0) {
|
||||
if (strongSelf.dataItemCount > 0) {
|
||||
[strongSelf persistDataItemQueue];
|
||||
} else {
|
||||
strongSelf.channelBlocked = NO;
|
||||
|
||||
@@ -66,6 +66,9 @@
|
||||
@property (nonatomic) NSInteger selectedAttachmentIndex;
|
||||
@property (nonatomic, strong) UITapGestureRecognizer *tapRecognizer;
|
||||
|
||||
@property (nonatomic) BOOL blockUserDataScreen;
|
||||
@property (nonatomic) BOOL actionSheetVisible;
|
||||
|
||||
/**
|
||||
* Workaround for UIImagePickerController bug.
|
||||
* The statusBar shows up when the UIImagePickerController opens.
|
||||
@@ -77,11 +80,7 @@
|
||||
@end
|
||||
|
||||
|
||||
@implementation BITFeedbackComposeViewController {
|
||||
BOOL _blockUserDataScreen;
|
||||
|
||||
BOOL _actionSheetVisible;
|
||||
}
|
||||
@implementation BITFeedbackComposeViewController
|
||||
|
||||
|
||||
#pragma mark - NSObject
|
||||
@@ -280,8 +279,8 @@
|
||||
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
if (_text && self.textView.text.length == 0) {
|
||||
self.textView.text = _text;
|
||||
if (self.text && self.textView.text.length == 0) {
|
||||
self.textView.text = self.text;
|
||||
}
|
||||
|
||||
if (self.isStatusBarHiddenBeforeShowingPhotoPicker) {
|
||||
@@ -316,7 +315,7 @@
|
||||
([self.manager requireManualUserDataMissing] ||
|
||||
![self.manager didAskUserData])
|
||||
) {
|
||||
if (!_blockUserDataScreen)
|
||||
if (!self.blockUserDataScreen)
|
||||
[self setUserDataAction];
|
||||
} else {
|
||||
// Invoke delayed to fix iOS 7 iPad landscape bug, where this view will be moved if not called delayed
|
||||
@@ -491,7 +490,7 @@
|
||||
}
|
||||
|
||||
- (void)addPhotoAction:(id)sender {
|
||||
if (_actionSheetVisible) return;
|
||||
if (self.actionSheetVisible) return;
|
||||
|
||||
self.isStatusBarHiddenBeforeShowingPhotoPicker = @([[UIApplication sharedApplication] isStatusBarHidden]);
|
||||
|
||||
@@ -597,7 +596,7 @@
|
||||
#pragma clang diagnostic push
|
||||
/*}*/
|
||||
|
||||
_actionSheetVisible = YES;
|
||||
self.actionSheetVisible = YES;
|
||||
if ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || ([[NSProcessInfo processInfo] respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)] && [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){9,0,0}])) {
|
||||
[self.textView resignFirstResponder];
|
||||
}
|
||||
@@ -607,7 +606,7 @@
|
||||
#pragma mark - BITFeedbackUserDataDelegate
|
||||
|
||||
- (void)userDataUpdateCancelled {
|
||||
_blockUserDataScreen = YES;
|
||||
self.blockUserDataScreen = YES;
|
||||
|
||||
if ([self.manager requireManualUserDataMissing]) {
|
||||
if ([self.navigationController respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
|
||||
@@ -684,7 +683,7 @@
|
||||
} else {
|
||||
[self cancelAction];
|
||||
}
|
||||
_actionSheetVisible = NO;
|
||||
self.actionSheetVisible = NO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -125,8 +125,8 @@
|
||||
|
||||
- (void) registerObservers {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
if (nil == _updateAttachmentNotification) {
|
||||
_updateAttachmentNotification = [[NSNotificationCenter defaultCenter] addObserverForName:kBITFeedbackUpdateAttachmentThumbnail
|
||||
if (nil == self.updateAttachmentNotification) {
|
||||
self.updateAttachmentNotification = [[NSNotificationCenter defaultCenter] addObserverForName:kBITFeedbackUpdateAttachmentThumbnail
|
||||
object:nil
|
||||
queue:NSOperationQueue.mainQueue
|
||||
usingBlock:^(NSNotification *note) {
|
||||
@@ -137,9 +137,9 @@
|
||||
}
|
||||
|
||||
- (void) unregisterObservers {
|
||||
if (_updateAttachmentNotification) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:_updateAttachmentNotification];
|
||||
_updateAttachmentNotification = nil;
|
||||
if (self.updateAttachmentNotification) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self.updateAttachmentNotification];
|
||||
self.updateAttachmentNotification = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@
|
||||
self.labelText.backgroundColor = [self backgroundColor];
|
||||
|
||||
self.labelTitle.textColor = TEXTCOLOR_TITLE;
|
||||
if (_message.status == BITFeedbackMessageStatusSendPending || _message.status == BITFeedbackMessageStatusSendInProgress) {
|
||||
if (self.message.status == BITFeedbackMessageStatusSendPending || self.message.status == BITFeedbackMessageStatusSendInProgress) {
|
||||
[self.labelText setTextColor:TEXTCOLOR_PENDING];
|
||||
} else {
|
||||
[self.labelText setTextColor:TEXTCOLOR_DEFAULT];
|
||||
@@ -282,19 +282,19 @@
|
||||
|
||||
// header
|
||||
NSString *dateString = @"";
|
||||
if (_message.status == BITFeedbackMessageStatusSendPending || _message.status == BITFeedbackMessageStatusSendInProgress) {
|
||||
if (self.message.status == BITFeedbackMessageStatusSendPending || self.message.status == BITFeedbackMessageStatusSendInProgress) {
|
||||
dateString = BITHockeyLocalizedString(@"Pending");
|
||||
} else if (_message.date) {
|
||||
if ([self isSameDayWithDate1:[NSDate date] date2:_message.date]) {
|
||||
dateString = [self.timeFormatter stringFromDate:_message.date];
|
||||
} else if (self.message.date) {
|
||||
if ([self isSameDayWithDate1:[NSDate date] date2:self.message.date]) {
|
||||
dateString = [self.timeFormatter stringFromDate:self.message.date];
|
||||
} else {
|
||||
dateString = [self.dateFormatter stringFromDate:_message.date];
|
||||
dateString = [self.dateFormatter stringFromDate:self.message.date];
|
||||
}
|
||||
}
|
||||
[self.labelTitle setText:dateString];
|
||||
[self.labelTitle setFrame:CGRectMake(FRAME_SIDE_BORDER, FRAME_TOP_BORDER + LABEL_TITLE_Y, self.frame.size.width - (2 * FRAME_SIDE_BORDER), LABEL_TITLE_HEIGHT)];
|
||||
|
||||
if (_message.userMessage) {
|
||||
if (self.message.userMessage) {
|
||||
self.labelTitle.textAlignment = NSTextAlignmentRight;
|
||||
self.labelText.textAlignment = NSTextAlignmentRight;
|
||||
} else {
|
||||
@@ -305,9 +305,9 @@
|
||||
[self addSubview:self.labelTitle];
|
||||
|
||||
// text
|
||||
[self.labelText setText:_message.text];
|
||||
[self.labelText setText:self.message.text];
|
||||
CGSize sizeForTextLabel = CGSizeMake(self.frame.size.width - (2 * FRAME_SIDE_BORDER),
|
||||
[[self class] heightForTextInRowWithMessage:_message tableViewWidth:self.frame.size.width] - LABEL_TEXT_Y - FRAME_BOTTOM_BORDER);
|
||||
[[self class] heightForTextInRowWithMessage:self.message tableViewWidth:self.frame.size.width] - LABEL_TEXT_Y - FRAME_BOTTOM_BORDER);
|
||||
|
||||
[self.labelText setFrame:CGRectMake(FRAME_SIDE_BORDER, LABEL_TEXT_Y, sizeForTextLabel.width, sizeForTextLabel.height)];
|
||||
|
||||
@@ -324,7 +324,7 @@
|
||||
imageButton.contentMode = UIViewContentModeScaleAspectFit;
|
||||
imageButton.imageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
|
||||
if (!_message.userMessage) {
|
||||
if (!self.message.userMessage) {
|
||||
imageButton.frame = CGRectMake(FRAME_SIDE_BORDER + (FRAME_SIDE_BORDER + ATTACHMENT_SIZE) * (i%(int)attachmentsPerRow) , floor(i/attachmentsPerRow)*(FRAME_SIDE_BORDER + ATTACHMENT_SIZE) + baseOffsetOfText , ATTACHMENT_SIZE, ATTACHMENT_SIZE);
|
||||
} else {
|
||||
imageButton.frame = CGRectMake(self.frame.size.width - FRAME_SIDE_BORDER - ATTACHMENT_SIZE - ((FRAME_SIDE_BORDER + ATTACHMENT_SIZE) * (i%(int)attachmentsPerRow) ), floor(i/attachmentsPerRow)*(FRAME_SIDE_BORDER + ATTACHMENT_SIZE) + baseOffsetOfText , ATTACHMENT_SIZE, ATTACHMENT_SIZE);
|
||||
|
||||
@@ -61,24 +61,22 @@
|
||||
@property (nonatomic) BOOL userDataComposeFlow;
|
||||
@property (nonatomic, strong) NSArray *cachedPreviewItems;
|
||||
@property (nonatomic, strong) NSOperationQueue *thumbnailQueue;
|
||||
@property (nonatomic) NSInteger deleteButtonSection;
|
||||
@property (nonatomic) NSInteger userButtonSection;
|
||||
@property (nonatomic) NSInteger numberOfSectionsBeforeRotation;
|
||||
@property (nonatomic) NSInteger numberOfMessagesBeforeRotation;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation BITFeedbackListViewController {
|
||||
NSInteger _deleteButtonSection;
|
||||
NSInteger _userButtonSection;
|
||||
|
||||
NSInteger _numberOfSectionsBeforeRotation;
|
||||
NSInteger _numberOfMessagesBeforeRotation;
|
||||
}
|
||||
@implementation BITFeedbackListViewController
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewStyle)style {
|
||||
if ((self = [super initWithStyle:style])) {
|
||||
_manager = [BITHockeyManager sharedHockeyManager].feedbackManager;
|
||||
|
||||
_deleteButtonSection = -1;
|
||||
_userButtonSection = -1;
|
||||
self.userButtonSection = -1;
|
||||
_userDataComposeFlow = NO;
|
||||
|
||||
_numberOfSectionsBeforeRotation = -1;
|
||||
@@ -253,7 +251,7 @@
|
||||
}
|
||||
|
||||
- (void)deleteAllMessages {
|
||||
[_manager deleteAllMessages];
|
||||
[self.manager deleteAllMessages];
|
||||
[self refreshPreviewItems];
|
||||
|
||||
[self.tableView reloadData];
|
||||
@@ -411,14 +409,14 @@
|
||||
#pragma mark - UIViewController Rotation
|
||||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
_numberOfSectionsBeforeRotation = [self numberOfSectionsInTableView:self.tableView];
|
||||
_numberOfMessagesBeforeRotation = [self.manager numberOfMessages];
|
||||
self.numberOfSectionsBeforeRotation = [self numberOfSectionsInTableView:self.tableView];
|
||||
self.numberOfMessagesBeforeRotation = [self.manager numberOfMessages];
|
||||
[self.tableView reloadData];
|
||||
[self.tableView beginUpdates];
|
||||
[self.tableView endUpdates];
|
||||
|
||||
_numberOfSectionsBeforeRotation = -1;
|
||||
_numberOfMessagesBeforeRotation = -1;
|
||||
self.numberOfSectionsBeforeRotation = -1;
|
||||
self.numberOfMessagesBeforeRotation = -1;
|
||||
[self.tableView reloadData];
|
||||
|
||||
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
|
||||
@@ -432,20 +430,20 @@
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
if (_numberOfSectionsBeforeRotation >= 0)
|
||||
return _numberOfSectionsBeforeRotation;
|
||||
if (self.numberOfSectionsBeforeRotation >= 0)
|
||||
return self.numberOfSectionsBeforeRotation;
|
||||
|
||||
NSInteger sections = 2;
|
||||
_deleteButtonSection = -1;
|
||||
_userButtonSection = -1;
|
||||
self.deleteButtonSection = -1;
|
||||
self.userButtonSection = -1;
|
||||
|
||||
if ([self.manager isManualUserDataAvailable] || [self.manager didAskUserData]) {
|
||||
_userButtonSection = sections;
|
||||
self.userButtonSection = sections;
|
||||
sections++;
|
||||
}
|
||||
|
||||
if ([self.manager numberOfMessages] > 0) {
|
||||
_deleteButtonSection = sections;
|
||||
self.deleteButtonSection = sections;
|
||||
sections++;
|
||||
}
|
||||
|
||||
@@ -454,8 +452,8 @@
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
if (section == 1) {
|
||||
if (_numberOfMessagesBeforeRotation >= 0)
|
||||
return _numberOfMessagesBeforeRotation;
|
||||
if (self.numberOfMessagesBeforeRotation >= 0)
|
||||
return self.numberOfMessagesBeforeRotation;
|
||||
return [self.manager numberOfMessages];
|
||||
} else {
|
||||
return 1;
|
||||
@@ -516,7 +514,7 @@
|
||||
|
||||
if (indexPath.section == 0) {
|
||||
identifier = ButtonTopIdentifier;
|
||||
} else if (indexPath.section == _userButtonSection) {
|
||||
} else if (indexPath.section == self.userButtonSection) {
|
||||
identifier = ButtonBottomIdentifier;
|
||||
} else {
|
||||
identifier = ButtonDeleteIdentifier;
|
||||
@@ -551,7 +549,7 @@
|
||||
} else {
|
||||
titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButtonWriteResponse");
|
||||
}
|
||||
} else if (indexPath.section == _userButtonSection) {
|
||||
} else if (indexPath.section == self.userButtonSection) {
|
||||
if ([self.manager requireUserName] == BITFeedbackUserDataElementRequired ||
|
||||
([self.manager requireUserName] == BITFeedbackUserDataElementOptional && [self.manager userName] != nil)
|
||||
) {
|
||||
@@ -667,8 +665,8 @@
|
||||
BITFeedbackMessage *message = [self.manager messageAtIndex:indexPath.row];
|
||||
BOOL messageHasAttachments = ([message attachments].count > 0);
|
||||
|
||||
if ([_manager deleteMessageAtIndex:indexPath.row]) {
|
||||
if ([_manager numberOfMessages] > 0) {
|
||||
if ([self.manager deleteMessageAtIndex:indexPath.row]) {
|
||||
if ([self.manager numberOfMessages] > 0) {
|
||||
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
} else {
|
||||
[tableView reloadData];
|
||||
@@ -701,9 +699,9 @@
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (indexPath.section == 0) {
|
||||
[self newFeedbackAction:self];
|
||||
} else if (indexPath.section == _userButtonSection) {
|
||||
} else if (indexPath.section == self.userButtonSection) {
|
||||
[self setUserDataAction:self];
|
||||
} else if (indexPath.section == _deleteButtonSection) {
|
||||
} else if (indexPath.section == self.deleteButtonSection) {
|
||||
[self deleteAllMessagesAction:self];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,22 +61,19 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
|
||||
@interface BITFeedbackManager () <UIGestureRecognizerDelegate>
|
||||
|
||||
@property (nonatomic, strong) NSFileManager *fileManager;
|
||||
@property (nonatomic, strong) NSString *settingsFile;
|
||||
@property (nonatomic, weak) id appDidBecomeActiveObserver;
|
||||
@property (nonatomic, weak) id appDidEnterBackgroundObserver;
|
||||
@property (nonatomic, weak) id networkDidBecomeReachableObserver;
|
||||
@property (nonatomic) BOOL incomingMessagesAlertShowing;
|
||||
@property (nonatomic) BOOL didEnterBackgroundState;
|
||||
@property (nonatomic) BOOL networkRequestInProgress;
|
||||
@property (nonatomic) BITFeedbackObservationMode observationMode;
|
||||
|
||||
@end
|
||||
|
||||
@implementation BITFeedbackManager {
|
||||
NSFileManager *_fileManager;
|
||||
NSString *_settingsFile;
|
||||
|
||||
id _appDidBecomeActiveObserver;
|
||||
id _appDidEnterBackgroundObserver;
|
||||
id _networkDidBecomeReachableObserver;
|
||||
|
||||
BOOL _incomingMessagesAlertShowing;
|
||||
BOOL _didEnterBackgroundState;
|
||||
BOOL _networkRequestInProgress;
|
||||
|
||||
BITFeedbackObservationMode _observationMode;
|
||||
}
|
||||
@implementation BITFeedbackManager
|
||||
|
||||
#pragma mark - Initialization
|
||||
|
||||
@@ -98,7 +95,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
_token = nil;
|
||||
_lastMessageID = nil;
|
||||
|
||||
_feedbackList = [NSMutableArray array];
|
||||
self.feedbackList = [NSMutableArray array];
|
||||
|
||||
_fileManager = [[NSFileManager alloc] init];
|
||||
|
||||
@@ -117,11 +114,11 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
|
||||
- (void)didBecomeActiveActions {
|
||||
if ([self isFeedbackManagerDisabled]) return;
|
||||
if (!_didEnterBackgroundState) return;
|
||||
if (!self.didEnterBackgroundState) return;
|
||||
|
||||
_didEnterBackgroundState = NO;
|
||||
self.didEnterBackgroundState = NO;
|
||||
|
||||
if ([_feedbackList count] == 0) {
|
||||
if ([self.feedbackList count] == 0) {
|
||||
[self loadMessages];
|
||||
} else {
|
||||
[self updateAppDefinedUserData];
|
||||
@@ -133,10 +130,10 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (void)didEnterBackgroundActions {
|
||||
_didEnterBackgroundState = NO;
|
||||
self.didEnterBackgroundState = NO;
|
||||
|
||||
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
|
||||
_didEnterBackgroundState = YES;
|
||||
self.didEnterBackgroundState = YES;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,8 +141,8 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
|
||||
- (void)registerObservers {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
if (nil == _appDidEnterBackgroundObserver) {
|
||||
_appDidEnterBackgroundObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification
|
||||
if (nil == self.appDidEnterBackgroundObserver) {
|
||||
self.appDidEnterBackgroundObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification
|
||||
object:nil
|
||||
queue:NSOperationQueue.mainQueue
|
||||
usingBlock:^(NSNotification *note) {
|
||||
@@ -153,8 +150,8 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
[strongSelf didEnterBackgroundActions];
|
||||
}];
|
||||
}
|
||||
if (nil == _appDidBecomeActiveObserver) {
|
||||
_appDidBecomeActiveObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
|
||||
if (nil == self.appDidBecomeActiveObserver) {
|
||||
self.appDidBecomeActiveObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
|
||||
object:nil
|
||||
queue:NSOperationQueue.mainQueue
|
||||
usingBlock:^(NSNotification *note) {
|
||||
@@ -162,8 +159,8 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
[strongSelf didBecomeActiveActions];
|
||||
}];
|
||||
}
|
||||
if (nil == _networkDidBecomeReachableObserver) {
|
||||
_networkDidBecomeReachableObserver = [[NSNotificationCenter defaultCenter] addObserverForName:BITHockeyNetworkDidBecomeReachableNotification
|
||||
if (nil == self.networkDidBecomeReachableObserver) {
|
||||
self.networkDidBecomeReachableObserver = [[NSNotificationCenter defaultCenter] addObserverForName:BITHockeyNetworkDidBecomeReachableNotification
|
||||
object:nil
|
||||
queue:NSOperationQueue.mainQueue
|
||||
usingBlock:^(NSNotification *note) {
|
||||
@@ -174,17 +171,17 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (void)unregisterObservers {
|
||||
if (_appDidEnterBackgroundObserver) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:_appDidEnterBackgroundObserver];
|
||||
_appDidEnterBackgroundObserver = nil;
|
||||
if (self.appDidEnterBackgroundObserver) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self.appDidEnterBackgroundObserver];
|
||||
self.appDidEnterBackgroundObserver = nil;
|
||||
}
|
||||
if (_appDidBecomeActiveObserver) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:_appDidBecomeActiveObserver];
|
||||
_appDidBecomeActiveObserver = nil;
|
||||
if (self.appDidBecomeActiveObserver) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self.appDidBecomeActiveObserver];
|
||||
self.appDidBecomeActiveObserver = nil;
|
||||
}
|
||||
if (_networkDidBecomeReachableObserver) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:_networkDidBecomeReachableObserver];
|
||||
_networkDidBecomeReachableObserver = nil;
|
||||
if (self.networkDidBecomeReachableObserver) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self.networkDidBecomeReachableObserver];
|
||||
self.networkDidBecomeReachableObserver = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +210,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (void)showFeedbackListView {
|
||||
if (_currentFeedbackListViewController) {
|
||||
if (self.currentFeedbackListViewController) {
|
||||
BITHockeyLogDebug(@"INFO: update view already visible, aborting");
|
||||
return;
|
||||
}
|
||||
@@ -244,7 +241,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (void)showFeedbackComposeViewWithPreparedItems:(NSArray *)items {
|
||||
if (_currentFeedbackComposeViewController) {
|
||||
if (self.currentFeedbackComposeViewController) {
|
||||
BITHockeyLogDebug(@"INFO: Feedback view already visible, aborting");
|
||||
return;
|
||||
}
|
||||
@@ -273,7 +270,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
switch ([[UIApplication sharedApplication] applicationState]) {
|
||||
case UIApplicationStateActive:
|
||||
// we did startup, so yes we are coming from background
|
||||
_didEnterBackgroundState = YES;
|
||||
self.didEnterBackgroundState = YES;
|
||||
|
||||
[self didBecomeActiveActions];
|
||||
break;
|
||||
@@ -294,7 +291,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (void)updateMessagesList {
|
||||
if (_networkRequestInProgress) return;
|
||||
if (self.networkRequestInProgress) return;
|
||||
|
||||
NSArray *pendingMessages = [self messagesWithStatus:BITFeedbackMessageStatusSendPending];
|
||||
if ([pendingMessages count] > 0) {
|
||||
@@ -400,10 +397,10 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
BOOL userNameViaDelegate = [self updateUserNameUsingKeychainAndDelegate];
|
||||
BOOL userEmailViaDelegate = [self updateUserEmailUsingKeychainAndDelegate];
|
||||
|
||||
if (![_fileManager fileExistsAtPath:_settingsFile])
|
||||
if (![self.fileManager fileExistsAtPath:self.settingsFile])
|
||||
return;
|
||||
|
||||
NSData *codedData = [[NSData alloc] initWithContentsOfFile:_settingsFile];
|
||||
NSData *codedData = [[NSData alloc] initWithContentsOfFile:self.settingsFile];
|
||||
if (codedData == nil) return;
|
||||
|
||||
NSKeyedUnarchiver *unarchiver = nil;
|
||||
@@ -440,7 +437,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
if ([unarchiver containsValueForKey:kBITFeedbackUserDataAsked])
|
||||
_didAskUserData = YES;
|
||||
self.didAskUserData = YES;
|
||||
|
||||
if ([unarchiver containsValueForKey:kBITFeedbackToken]) {
|
||||
self.token = [unarchiver decodeObjectForKey:kBITFeedbackToken];
|
||||
@@ -492,7 +489,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
NSMutableData *data = [[NSMutableData alloc] init];
|
||||
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
|
||||
|
||||
if (_didAskUserData)
|
||||
if (self.didAskUserData)
|
||||
[archiver encodeObject:[NSNumber numberWithBool:YES] forKey:kBITFeedbackUserDataAsked];
|
||||
|
||||
if (self.token)
|
||||
@@ -519,13 +516,13 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
[archiver encodeObject:self.feedbackList forKey:kBITFeedbackMessages];
|
||||
|
||||
[archiver finishEncoding];
|
||||
[data writeToFile:_settingsFile atomically:YES];
|
||||
[data writeToFile:self.settingsFile atomically:YES];
|
||||
}
|
||||
|
||||
|
||||
- (void)updateDidAskUserData {
|
||||
if (!_didAskUserData) {
|
||||
_didAskUserData = YES;
|
||||
if (!self.didAskUserData) {
|
||||
self.didAskUserData = YES;
|
||||
|
||||
[self saveMessages];
|
||||
}
|
||||
@@ -534,7 +531,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
#pragma mark - Messages
|
||||
|
||||
- (void)sortFeedbackList {
|
||||
[_feedbackList sortUsingComparator:^(BITFeedbackMessage *obj1, BITFeedbackMessage *obj2) {
|
||||
[self.feedbackList sortUsingComparator:^(BITFeedbackMessage *obj1, BITFeedbackMessage *obj2) {
|
||||
NSDate *date1 = [obj1 date];
|
||||
NSDate *date2 = [obj2 date];
|
||||
|
||||
@@ -557,12 +554,12 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (NSUInteger)numberOfMessages {
|
||||
return [_feedbackList count];
|
||||
return [self.feedbackList count];
|
||||
}
|
||||
|
||||
- (BITFeedbackMessage *)messageAtIndex:(NSUInteger)index {
|
||||
if ([_feedbackList count] > index) {
|
||||
return [_feedbackList objectAtIndex:index];
|
||||
if ([self.feedbackList count] > index) {
|
||||
return [self.feedbackList objectAtIndex:index];
|
||||
}
|
||||
|
||||
return nil;
|
||||
@@ -571,7 +568,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
- (BITFeedbackMessage *)messageWithID:(NSNumber *)messageID {
|
||||
__block BITFeedbackMessage *message = nil;
|
||||
|
||||
[_feedbackList enumerateObjectsUsingBlock:^(BITFeedbackMessage *objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
[self.feedbackList enumerateObjectsUsingBlock:^(BITFeedbackMessage *objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
if ([[objMessage identifier] isEqualToNumber:messageID]) {
|
||||
message = objMessage;
|
||||
*stop = YES;
|
||||
@@ -582,9 +579,9 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (NSArray *)messagesWithStatus:(BITFeedbackMessageStatus)status {
|
||||
NSMutableArray *resultMessages = [[NSMutableArray alloc] initWithCapacity:[_feedbackList count]];
|
||||
NSMutableArray *resultMessages = [[NSMutableArray alloc] initWithCapacity:[self.feedbackList count]];
|
||||
|
||||
[_feedbackList enumerateObjectsUsingBlock:^(BITFeedbackMessage *objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
[self.feedbackList enumerateObjectsUsingBlock:^(BITFeedbackMessage *objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
if ([objMessage status] == status) {
|
||||
[resultMessages addObject:objMessage];
|
||||
}
|
||||
@@ -597,9 +594,9 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
__block BITFeedbackMessage *message = nil;
|
||||
|
||||
|
||||
// Note: the logic here is slightly different than in our mac SDK, as _feedbackList is sorted in different order.
|
||||
// Note: the logic here is slightly different than in our mac SDK, as self.feedbackList is sorted in different order.
|
||||
// Compare the implementation of - (void)sortFeedbackList; in both SDKs.
|
||||
[_feedbackList enumerateObjectsUsingBlock:^(BITFeedbackMessage *objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
[self.feedbackList enumerateObjectsUsingBlock:^(BITFeedbackMessage *objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
if ([[objMessage identifier] integerValue] != 0) {
|
||||
message = objMessage;
|
||||
*stop = YES;
|
||||
@@ -611,7 +608,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
|
||||
- (void)markSendInProgressMessagesAsPending {
|
||||
// make sure message that may have not been send successfully, get back into the right state to be send again
|
||||
[_feedbackList enumerateObjectsUsingBlock:^(id objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
[self.feedbackList enumerateObjectsUsingBlock:^(id objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
if ([(BITFeedbackMessage *) objMessage status] == BITFeedbackMessageStatusSendInProgress)
|
||||
[(BITFeedbackMessage *) objMessage setStatus:BITFeedbackMessageStatusSendPending];
|
||||
}];
|
||||
@@ -619,7 +616,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
|
||||
- (void)markSendInProgressMessagesAsInConflict {
|
||||
// make sure message that may have not been send successfully, get back into the right state to be send again
|
||||
[_feedbackList enumerateObjectsUsingBlock:^(id objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
[self.feedbackList enumerateObjectsUsingBlock:^(id objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
if ([(BITFeedbackMessage *) objMessage status] == BITFeedbackMessageStatusSendInProgress)
|
||||
[(BITFeedbackMessage *) objMessage setStatus:BITFeedbackMessageStatusInConflict];
|
||||
}];
|
||||
@@ -634,10 +631,10 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (BOOL)deleteMessageAtIndex:(NSUInteger)index {
|
||||
if (_feedbackList && [_feedbackList count] > index && [_feedbackList objectAtIndex:index]) {
|
||||
BITFeedbackMessage *message = _feedbackList[index];
|
||||
if (self.feedbackList && [self.feedbackList count] > index && [self.feedbackList objectAtIndex:index]) {
|
||||
BITFeedbackMessage *message = self.feedbackList[index];
|
||||
[message deleteContents];
|
||||
[_feedbackList removeObjectAtIndex:index];
|
||||
[self.feedbackList removeObjectAtIndex:index];
|
||||
|
||||
[self saveMessages];
|
||||
return YES;
|
||||
@@ -647,7 +644,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (void)deleteAllMessages {
|
||||
[_feedbackList removeAllObjects];
|
||||
[self.feedbackList removeAllObjects];
|
||||
|
||||
[self saveMessages];
|
||||
}
|
||||
@@ -707,7 +704,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
|
||||
[self markSendInProgressMessagesAsPending];
|
||||
|
||||
[_feedbackList enumerateObjectsUsingBlock:^(id objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
[self.feedbackList enumerateObjectsUsingBlock:^(id objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
if ([(BITFeedbackMessage *) objMessage status] != BITFeedbackMessageStatusSendPending)
|
||||
[(BITFeedbackMessage *) objMessage setStatus:BITFeedbackMessageStatusArchived];
|
||||
}];
|
||||
@@ -804,7 +801,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
[message addAttachmentsObject:newAttachment];
|
||||
}
|
||||
|
||||
[_feedbackList addObject:message];
|
||||
[self.feedbackList addObject:message];
|
||||
|
||||
newMessage = YES;
|
||||
}
|
||||
@@ -871,7 +868,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
[alertView show];
|
||||
#pragma clang diagnostic pop
|
||||
/*}*/
|
||||
_incomingMessagesAlertShowing = YES;
|
||||
self.incomingMessagesAlertShowing = YES;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -897,7 +894,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
- (void)sendNetworkRequestWithHTTPMethod:(NSString *)httpMethod withMessage:(BITFeedbackMessage *)message completionHandler:(void (^)(NSError *error))completionHandler {
|
||||
NSString *boundary = @"----FOO";
|
||||
|
||||
_networkRequestInProgress = YES;
|
||||
self.networkRequestInProgress = YES;
|
||||
// inform the UI to update its data in case the list is already showing
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:BITHockeyFeedbackMessagesLoadingStarted object:nil];
|
||||
|
||||
@@ -1010,7 +1007,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (void)handleFeedbackMessageResponse:(NSURLResponse *)response data:(NSData *)responseData error:(NSError *)error completion:(void (^)(NSError *error))completionHandler {
|
||||
_networkRequestInProgress = NO;
|
||||
self.networkRequestInProgress = NO;
|
||||
|
||||
if (error) {
|
||||
[self reportError:error];
|
||||
@@ -1030,7 +1027,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
// set the token to the first message token, since this is identical
|
||||
__block NSString *token = nil;
|
||||
|
||||
[_feedbackList enumerateObjectsUsingBlock:^(id objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
[self.feedbackList enumerateObjectsUsingBlock:^(id objMessage, NSUInteger messagesIdx, BOOL *stop) {
|
||||
if ([(BITFeedbackMessage *) objMessage status] == BITFeedbackMessageStatusSendInProgress) {
|
||||
token = [(BITFeedbackMessage *) objMessage token];
|
||||
*stop = YES;
|
||||
@@ -1083,7 +1080,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (void)fetchMessageUpdates {
|
||||
if ([_feedbackList count] == 0 && !self.token) {
|
||||
if ([self.feedbackList count] == 0 && !self.token) {
|
||||
// inform the UI to update its data in case the list is already showing
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:BITHockeyFeedbackMessagesLoadingFinished object:nil];
|
||||
|
||||
@@ -1099,7 +1096,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (void)submitPendingMessages {
|
||||
if (_networkRequestInProgress) {
|
||||
if (self.networkRequestInProgress) {
|
||||
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(submitPendingMessages) object:nil];
|
||||
[self performSelector:@selector(submitPendingMessages) withObject:nil afterDelay:2.0];
|
||||
return;
|
||||
@@ -1150,7 +1147,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
[message setAttachments:attachments];
|
||||
[message setUserMessage:YES];
|
||||
|
||||
[_feedbackList addObject:message];
|
||||
[self.feedbackList addObject:message];
|
||||
|
||||
[self submitPendingMessages];
|
||||
}
|
||||
@@ -1164,7 +1161,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
// invoke the selected action from the action sheet for a location element
|
||||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
|
||||
|
||||
_incomingMessagesAlertShowing = NO;
|
||||
self.incomingMessagesAlertShowing = NO;
|
||||
if (buttonIndex == [alertView firstOtherButtonIndex]) {
|
||||
// Show button has been clicked
|
||||
[self showFeedbackListView];
|
||||
|
||||
@@ -28,22 +28,25 @@
|
||||
|
||||
#import "BITHTTPOperation.h"
|
||||
|
||||
@interface BITHTTPOperation()<NSURLConnectionDelegate>
|
||||
@interface BITHTTPOperation() <NSURLConnectionDelegate>
|
||||
|
||||
@property (nonatomic, strong) NSURLRequest *URLRequest;
|
||||
@property (nonatomic, strong) NSURLConnection *connection;
|
||||
@property (nonatomic, strong) NSMutableData *mutableData;
|
||||
@property (nonatomic) BOOL isExecuting;
|
||||
@property (nonatomic) BOOL isFinished;
|
||||
|
||||
// Redeclare BITHTTPOperation properties with readwrite attribute.
|
||||
@property (nonatomic, readwrite) NSHTTPURLResponse *response;
|
||||
@property (nonatomic, readwrite) NSError *error;
|
||||
|
||||
@end
|
||||
|
||||
@implementation BITHTTPOperation {
|
||||
NSURLRequest *_URLRequest;
|
||||
NSURLConnection *_connection;
|
||||
NSMutableData *_data;
|
||||
|
||||
BOOL _isExecuting;
|
||||
BOOL _isFinished;
|
||||
}
|
||||
|
||||
@implementation BITHTTPOperation
|
||||
|
||||
+ (instancetype)operationWithRequest:(NSURLRequest *)urlRequest {
|
||||
BITHTTPOperation *op = [[self class] new];
|
||||
op->_URLRequest = urlRequest;
|
||||
op.URLRequest = urlRequest;
|
||||
return op;
|
||||
}
|
||||
|
||||
@@ -53,7 +56,7 @@
|
||||
}
|
||||
|
||||
- (void)cancel {
|
||||
[_connection cancel];
|
||||
[self.connection cancel];
|
||||
[super cancel];
|
||||
}
|
||||
|
||||
@@ -74,12 +77,12 @@
|
||||
}
|
||||
|
||||
[self willChangeValueForKey:@"isExecuting"];
|
||||
_isExecuting = YES;
|
||||
self.isExecuting = YES;
|
||||
[self didChangeValueForKey:@"isExecuting"];
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
_connection = [[NSURLConnection alloc] initWithRequest:_URLRequest
|
||||
self.connection = [[NSURLConnection alloc] initWithRequest:self.URLRequest
|
||||
delegate:self
|
||||
startImmediately:YES];
|
||||
#pragma clang diagnostic pop
|
||||
@@ -88,26 +91,26 @@
|
||||
- (void) finish {
|
||||
[self willChangeValueForKey:@"isExecuting"];
|
||||
[self willChangeValueForKey:@"isFinished"];
|
||||
_isExecuting = NO;
|
||||
_isFinished = YES;
|
||||
self.isExecuting = NO;
|
||||
self.isFinished = YES;
|
||||
[self didChangeValueForKey:@"isExecuting"];
|
||||
[self didChangeValueForKey:@"isFinished"];
|
||||
}
|
||||
|
||||
#pragma mark - NSURLConnectionDelegate
|
||||
-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response {
|
||||
_data = [[NSMutableData alloc] init];
|
||||
_response = (id)response;
|
||||
self.mutableData = [[NSMutableData alloc] init];
|
||||
self.response = (id)response;
|
||||
}
|
||||
|
||||
-(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data {
|
||||
[_data appendData:data];
|
||||
[self.mutableData appendData:data];
|
||||
}
|
||||
|
||||
-(void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error {
|
||||
//FINISHED and failed
|
||||
_error = error;
|
||||
_data = nil;
|
||||
self.error = error;
|
||||
self.mutableData = nil;
|
||||
|
||||
[self finish];
|
||||
}
|
||||
@@ -118,7 +121,7 @@
|
||||
|
||||
#pragma mark - Public interface
|
||||
- (NSData *)data {
|
||||
return _data;
|
||||
return self.mutableData;
|
||||
}
|
||||
|
||||
- (void)setCompletion:(BITNetworkCompletionBlock)completion {
|
||||
@@ -131,7 +134,7 @@
|
||||
if(strongSelf) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if(!strongSelf.isCancelled) {
|
||||
completion(strongSelf, strongSelf->_data, strongSelf->_error);
|
||||
completion(strongSelf, strongSelf.data, strongSelf.error);
|
||||
}
|
||||
[strongSelf setCompletionBlock:nil];
|
||||
});
|
||||
|
||||
@@ -21,9 +21,13 @@ static NSString *const kBITMetaDataDirectory = @"MetaData";
|
||||
static char const *kBITPersistenceQueueString = "com.microsoft.HockeyApp.persistenceQueue";
|
||||
static NSUInteger const BITDefaultFileCount = 50;
|
||||
|
||||
@implementation BITPersistence {
|
||||
BOOL _directorySetupComplete;
|
||||
}
|
||||
@interface BITPersistence ()
|
||||
|
||||
@property (nonatomic) BOOL directorySetupComplete;
|
||||
|
||||
@end
|
||||
|
||||
@implementation BITPersistence
|
||||
|
||||
#pragma mark - Public
|
||||
|
||||
@@ -79,7 +83,7 @@ static NSUInteger const BITDefaultFileCount = 50;
|
||||
|
||||
- (BOOL)isFreeSpaceAvailable {
|
||||
NSArray *files = [self persistedFilesForType:BITPersistenceTypeTelemetry];
|
||||
return files.count < _maxFileCount;
|
||||
return files.count < self.maxFileCount;
|
||||
}
|
||||
|
||||
- (NSString *)requestNextFilePath {
|
||||
@@ -227,7 +231,7 @@ static NSUInteger const BITDefaultFileCount = 50;
|
||||
BITHockeyLogDebug(@"INFO: Exclude %@ from backup", appURL);
|
||||
}
|
||||
|
||||
_directorySetupComplete = YES;
|
||||
self.directorySetupComplete = YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user