intern Pastelog back into Signal.
Not worth the cocaopods/framework/project mgmt machinery for making changes to 1 class. // FREEBIE
This commit is contained in:
parent
c88f275c9a
commit
8adba61b37
1
Podfile
1
Podfile
|
@ -8,7 +8,6 @@ target 'Signal' do
|
|||
pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
|
||||
#pod 'SignalServiceKit', path: '../SignalServiceKit'
|
||||
pod 'OpenSSL'
|
||||
pod 'PastelogKit', '~> 1.3'
|
||||
pod 'FFCircularProgressView', '~> 0.5'
|
||||
pod 'SCWaveformView', '~> 1.0'
|
||||
pod 'JSQMessagesViewController'
|
||||
|
|
|
@ -37,8 +37,6 @@ PODS:
|
|||
- Mantle/extobjc (= 2.1.0)
|
||||
- Mantle/extobjc (2.1.0)
|
||||
- OpenSSL (1.0.210)
|
||||
- PastelogKit (1.3):
|
||||
- CocoaLumberjack (~> 2.0)
|
||||
- ProtocolBuffers (1.9.11)
|
||||
- PureLayout (3.0.2)
|
||||
- Reachability (3.2)
|
||||
|
@ -117,7 +115,6 @@ DEPENDENCIES:
|
|||
- FFCircularProgressView (~> 0.5)
|
||||
- JSQMessagesViewController
|
||||
- OpenSSL
|
||||
- PastelogKit (~> 1.3)
|
||||
- PureLayout
|
||||
- SCWaveformView (~> 1.0)
|
||||
- SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`)
|
||||
|
@ -154,7 +151,6 @@ SPEC CHECKSUMS:
|
|||
libPhoneNumber-iOS: 63bab980d1fc9783d82d955800ac9d7c1d81fde3
|
||||
Mantle: 2fa750afa478cd625a94230fbf1c13462f29395b
|
||||
OpenSSL: 246ffb948e9d56466727fd318134af35f5aa764e
|
||||
PastelogKit: 7b475be4cf577713506a943dd940bcc0499c8bca
|
||||
ProtocolBuffers: d509225eb2ea43d9582a59e94348fcf86e2abd65
|
||||
PureLayout: 4d550abe49a94f24c2808b9b95db9131685fe4cd
|
||||
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
|
||||
|
@ -167,6 +163,6 @@ SPEC CHECKSUMS:
|
|||
UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d
|
||||
YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f
|
||||
|
||||
PODFILE CHECKSUM: 7088298933b189805c955880c8d1be86da3078af
|
||||
PODFILE CHECKSUM: e1b30ecf8ba192005de35b7e0928ed01ae8a91ba
|
||||
|
||||
COCOAPODS: 1.1.1
|
||||
COCOAPODS: 1.2.0
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
456F6E251E24216100FD2210 /* DataChannelMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45464DBB1DFA041F001D3FD6 /* DataChannelMessage.swift */; };
|
||||
456F6E2F1E261D1000FD2210 /* PeerConnectionClientTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 456F6E2E1E261D1000FD2210 /* PeerConnectionClientTest.swift */; };
|
||||
4574A5D61DD6704700C6B692 /* CallService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4574A5D51DD6704700C6B692 /* CallService.swift */; };
|
||||
4579431E1E7C8CE9008ED0C0 /* Pastelog.m in Sources */ = {isa = PBXBuildFile; fileRef = 4579431D1E7C8CE9008ED0C0 /* Pastelog.m */; };
|
||||
45794E861E00620000066731 /* CallUIAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45794E851E00620000066731 /* CallUIAdapter.swift */; };
|
||||
45843D1F1D2236B30013E85A /* OWSContactsSearcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 45843D1E1D2236B30013E85A /* OWSContactsSearcher.m */; };
|
||||
45843D201D2236B30013E85A /* OWSContactsSearcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 45843D1E1D2236B30013E85A /* OWSContactsSearcher.m */; };
|
||||
|
@ -691,6 +692,8 @@
|
|||
45666F7D1D9C0814008FE134 /* OWSDatabaseMigrationRunner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSDatabaseMigrationRunner.m; path = Migrations/OWSDatabaseMigrationRunner.m; sourceTree = "<group>"; };
|
||||
456F6E2E1E261D1000FD2210 /* PeerConnectionClientTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PeerConnectionClientTest.swift; sourceTree = "<group>"; };
|
||||
4574A5D51DD6704700C6B692 /* CallService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CallService.swift; sourceTree = "<group>"; };
|
||||
4579431C1E7C8CE9008ED0C0 /* Pastelog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pastelog.h; sourceTree = "<group>"; };
|
||||
4579431D1E7C8CE9008ED0C0 /* Pastelog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Pastelog.m; sourceTree = "<group>"; };
|
||||
45794E851E00620000066731 /* CallUIAdapter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CallUIAdapter.swift; path = UserInterface/CallUIAdapter.swift; sourceTree = "<group>"; };
|
||||
45843D1D1D2236B30013E85A /* OWSContactsSearcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactsSearcher.h; sourceTree = "<group>"; };
|
||||
45843D1E1D2236B30013E85A /* OWSContactsSearcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactsSearcher.m; sourceTree = "<group>"; };
|
||||
|
@ -1972,6 +1975,8 @@
|
|||
76EB04C818170B33006006FC /* util */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4579431C1E7C8CE9008ED0C0 /* Pastelog.h */,
|
||||
4579431D1E7C8CE9008ED0C0 /* Pastelog.m */,
|
||||
B68EF9B51C0B1E7D009C3DCD /* Animated GIFS */,
|
||||
B6DA6B051B8A2F9A00CA6F98 /* AppStoreRating.h */,
|
||||
B6DA6B061B8A2F9A00CA6F98 /* AppStoreRating.m */,
|
||||
|
@ -3341,6 +3346,7 @@
|
|||
45666F7E1D9C0814008FE134 /* OWSDatabaseMigrationRunner.m in Sources */,
|
||||
B63761E319E1F487005735D1 /* AFHTTPSessionManager+SignalMethods.m in Sources */,
|
||||
76EB05CC18170B33006006FC /* ShortAuthenticationStringGenerator.m in Sources */,
|
||||
4579431E1E7C8CE9008ED0C0 /* Pastelog.m in Sources */,
|
||||
E16E5BEF18AAC40200B7C403 /* EC25KeyAgreementProtocol.m in Sources */,
|
||||
45C681BC1D305C080050903A /* OWSCallCollectionViewCell.m in Sources */,
|
||||
76EB064018170B33006006FC /* AnonymousTerminator.m in Sources */,
|
||||
|
|
|
@ -21,6 +21,5 @@
|
|||
#import <SignalServiceKit/OWSDispatch.h>
|
||||
#import "iOSVersions.h"
|
||||
|
||||
#define SignalAlertView(title,msg) [[[UIAlertView alloc] initWithTitle:title message:msg delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil, nil] show]
|
||||
#define SignalReportError [Pastelog reportErrorAndSubmitLogsWithAlertTitle:NSLocalizedString(@"ERROR_WAS_DETECTED_TITLE", @"") alertBody:NSLocalizedString(@"ERROR_WAS_DETECTED_SUBMIT", @"")];
|
||||
#define SignalAlertView(title,msg) [[[UIAlertView alloc] initWithTitle:title message:msg delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil, nil] show]
|
||||
#endif
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#import "TextSecureKitEnv.h"
|
||||
#import "VersionMigrations.h"
|
||||
#import <AxolotlKit/SessionCipher.h>
|
||||
#import <PastelogKit/Pastelog.h>
|
||||
#import "Pastelog.h"
|
||||
#import <PromiseKit/AnyPromise.h>
|
||||
#import <SignalServiceKit/OWSDisappearingMessagesJob.h>
|
||||
#import <SignalServiceKit/OWSFailedMessagesJob.h>
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
@interface Pastelog : NSObject <NSURLConnectionDelegate, NSURLConnectionDataDelegate, UIAlertViewDelegate>
|
||||
|
||||
typedef void (^successBlock)(NSError *error, NSString *urlString);
|
||||
|
||||
+(void)reportErrorAndSubmitLogsWithAlertTitle:(NSString*)alertTitle alertBody:(NSString*)alertBody;
|
||||
+(void)reportErrorAndSubmitLogsWithAlertTitle:(NSString*)alertTitle alertBody:(NSString*)alertBody completionBlock:(successBlock)block;
|
||||
|
||||
+(void)submitLogs;
|
||||
+(void)submitLogsWithCompletion:(successBlock)block;
|
||||
+(void)submitLogsWithCompletion:(successBlock)block forFileLogger:(DDFileLogger*)fileLogger;
|
||||
|
||||
@end
|
|
@ -0,0 +1,205 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Pastelog.h"
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
@interface Pastelog ()
|
||||
|
||||
@property (nonatomic)UIAlertView *reportAlertView;
|
||||
@property (nonatomic)UIAlertView *loadingAlertView;
|
||||
@property (nonatomic)UIAlertView *submitAlertView;
|
||||
@property (nonatomic)UIAlertView *infoAlertView;
|
||||
@property (nonatomic)NSMutableData *responseData;
|
||||
@property (nonatomic, copy)successBlock block;
|
||||
@property (nonatomic, copy)NSString *gistURL;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation Pastelog
|
||||
|
||||
+(void)reportErrorAndSubmitLogsWithAlertTitle:(NSString*)alertTitle alertBody:(NSString*)alertBody {
|
||||
[self reportErrorAndSubmitLogsWithAlertTitle:alertTitle alertBody:alertBody completionBlock:nil];
|
||||
}
|
||||
|
||||
+(void)reportErrorAndSubmitLogsWithAlertTitle:(NSString*)alertTitle alertBody:(NSString*)alertBody completionBlock:(successBlock)block {
|
||||
Pastelog *sharedManager = [self sharedManager];
|
||||
sharedManager.block = block;
|
||||
sharedManager.reportAlertView = [[UIAlertView alloc] initWithTitle:alertTitle message:alertBody delegate:[self sharedManager] cancelButtonTitle:@"Yes" otherButtonTitles:@"No", nil];
|
||||
[sharedManager.reportAlertView show];
|
||||
}
|
||||
|
||||
+(void)submitLogs {
|
||||
Pastelog *sharedManager = [self sharedManager];
|
||||
[self submitLogsWithCompletion:^(NSError *error, NSString *urlString) {
|
||||
if (!error) {
|
||||
sharedManager.gistURL = urlString;
|
||||
sharedManager.submitAlertView = [[UIAlertView alloc] initWithTitle:@"One More Step" message:@"What would you like to do with the link to your debug log?" delegate:[self sharedManager] cancelButtonTitle:@"Create GitHub Issue" otherButtonTitles:@"Email Link", @"Copy Link", nil];
|
||||
[sharedManager.submitAlertView show];
|
||||
} else{
|
||||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Failed to submit debug log" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
|
||||
[alertView show];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
+(void)submitLogsWithCompletion:(successBlock)block {
|
||||
[self submitLogsWithCompletion:(successBlock)block forFileLogger:[[DDFileLogger alloc] init]];
|
||||
}
|
||||
|
||||
+(void)submitLogsWithCompletion:(successBlock)block forFileLogger:(DDFileLogger*)fileLogger {
|
||||
|
||||
[self sharedManager].block = block;
|
||||
|
||||
[self sharedManager].loadingAlertView = [[UIAlertView alloc] initWithTitle:@"Sending debug log..."
|
||||
message:nil delegate:self
|
||||
cancelButtonTitle:nil
|
||||
otherButtonTitles:nil];
|
||||
[[self sharedManager].loadingAlertView show];
|
||||
|
||||
NSArray *fileNames = fileLogger.logFileManager.sortedLogFileNames;
|
||||
NSArray *filePaths = fileLogger.logFileManager.sortedLogFilePaths;
|
||||
|
||||
NSMutableDictionary *gistFiles = [@{} mutableCopy];
|
||||
|
||||
NSError *error;
|
||||
|
||||
for (unsigned int i = 0; i < [filePaths count]; i++) {
|
||||
[gistFiles setObject:@{@"content":[NSString stringWithContentsOfFile:[filePaths objectAtIndex:i] encoding:NSUTF8StringEncoding error:&error]} forKey:[fileNames objectAtIndex:i]];
|
||||
}
|
||||
|
||||
if (error) {
|
||||
}
|
||||
|
||||
NSDictionary *gistDict = @{@"description":[self gistDescription], @"files":gistFiles};
|
||||
|
||||
NSData *postData = [NSJSONSerialization dataWithJSONObject:gistDict options:0 error:nil];
|
||||
|
||||
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:@"https://api.github.com/gists"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30];
|
||||
|
||||
[[self sharedManager] setResponseData:[NSMutableData data]];
|
||||
[[self sharedManager] setBlock:block];
|
||||
|
||||
[request setHTTPMethod:@"POST"];
|
||||
[request setHTTPBody:postData];
|
||||
|
||||
NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:[self sharedManager]];
|
||||
|
||||
[connection start];
|
||||
|
||||
}
|
||||
|
||||
+(Pastelog*)sharedManager {
|
||||
static Pastelog *sharedMyManager = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedMyManager = [[self alloc] init];
|
||||
});
|
||||
return sharedMyManager;
|
||||
}
|
||||
|
||||
-(instancetype)init {
|
||||
if (self = [super init]) {
|
||||
self.responseData = [NSMutableData data];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+(NSString*)gistDescription{
|
||||
size_t size;
|
||||
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
|
||||
char *machine = malloc(size);
|
||||
sysctlbyname("hw.machine", machine, &size, NULL, 0);
|
||||
NSString *platform = [NSString stringWithUTF8String:machine];
|
||||
free(machine);
|
||||
|
||||
NSString *gistDesc = [NSString stringWithFormat:@"iPhone Version: %@, iOS Version: %@", platform,[UIDevice currentDevice].systemVersion];
|
||||
|
||||
return gistDesc;
|
||||
}
|
||||
|
||||
#pragma mark Network delegates
|
||||
|
||||
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
|
||||
[self.responseData appendData:data];
|
||||
}
|
||||
|
||||
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
|
||||
[self.loadingAlertView dismissWithClickedButtonIndex:0 animated:YES];
|
||||
|
||||
NSError *error;
|
||||
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:self.responseData options:0 error:&error];
|
||||
if (!error) {
|
||||
self.block(nil, [dict objectForKey:@"html_url"]);
|
||||
} else{
|
||||
DDLogError(@"Error on debug response: %@", error);
|
||||
self.block(error, nil);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
|
||||
|
||||
NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
|
||||
|
||||
if ( [httpResponse statusCode] != 201) {
|
||||
DDLogError(@"Failed to submit debug log: %@", httpResponse.debugDescription);
|
||||
[self.loadingAlertView dismissWithClickedButtonIndex:0 animated:YES];
|
||||
[connection cancel];
|
||||
self.block([NSError errorWithDomain:@"PastelogKit" code:10001 userInfo:@{}],nil);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
|
||||
[self.loadingAlertView dismissWithClickedButtonIndex:0 animated:YES];
|
||||
DDLogError(@"Uploading logs failed with error: %@", error);
|
||||
self.block(error,nil);
|
||||
}
|
||||
|
||||
#pragma mark Alert View Delegates
|
||||
|
||||
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
|
||||
if (alertView == self.reportAlertView) {
|
||||
if (buttonIndex == 0) {
|
||||
if (self.block) {
|
||||
[[self class] submitLogsWithCompletion:self.block];
|
||||
} else{
|
||||
[[self class] submitLogs];
|
||||
}
|
||||
|
||||
} else{
|
||||
// User declined, nevermind.
|
||||
}
|
||||
} else if (alertView == self.submitAlertView) {
|
||||
if (buttonIndex == 0) {
|
||||
[self prepareRedirection:self.gistURL];
|
||||
} else if (buttonIndex == 1) {
|
||||
[self submitEmail:self.gistURL];
|
||||
} else {
|
||||
UIPasteboard *pb = [UIPasteboard generalPasteboard];
|
||||
[pb setString:self.gistURL];
|
||||
}
|
||||
} else if (alertView == self.infoAlertView) {
|
||||
[UIApplication.sharedApplication openURL:[NSURL URLWithString:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"LOGS_URL"]]];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark Logs submission
|
||||
|
||||
- (void)submitEmail:(NSString*)url {
|
||||
NSString *emailAddress = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"LOGS_EMAIL"];
|
||||
|
||||
NSString *urlString = [NSString stringWithString: [[NSString stringWithFormat:@"mailto:%@?subject=iOS%%20Debug%%20Log&body=", emailAddress] stringByAppendingString:[[NSString stringWithFormat:@"Log URL: %@ \n Tell us about the issue: ", url]stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]];
|
||||
|
||||
[UIApplication.sharedApplication openURL: [NSURL URLWithString: urlString]];
|
||||
}
|
||||
|
||||
- (void)prepareRedirection:(NSString*)url {
|
||||
UIPasteboard *pb = [UIPasteboard generalPasteboard];
|
||||
[pb setString:url];
|
||||
self.infoAlertView = [[UIAlertView alloc]initWithTitle:@"GitHub redirection" message:@"The gist link was copied in your clipboard. You are about to be redirected to the GitHub issue list." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
|
||||
[self.infoAlertView show];
|
||||
}
|
||||
|
||||
@end
|
|
@ -11,7 +11,7 @@
|
|||
#import "Signal-Swift.h"
|
||||
#import "TSAccountManager.h"
|
||||
#import "UIViewController+OWS.h"
|
||||
#import <PastelogKit/Pastelog.h>
|
||||
#import "Pastelog.h"
|
||||
#import <PromiseKit/AnyPromise.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
|
Loading…
Reference in New Issue