Adding more logging to address the initialization issues

This commit is contained in:
Frederic Jacobs 2014-07-06 19:18:56 +02:00
parent e8b9a831d8
commit fe41d3379c
10 changed files with 28 additions and 8 deletions

View File

@ -12,7 +12,8 @@
#ifdef DEBUG
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
#else
static const int ddLogLevel = LOG_LEVEL_WARN;
// As long as we have call initialization issues we'll log a bit more aggressively
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
#endif
#endif

View File

@ -108,7 +108,10 @@
}
[[[Environment phoneManager] currentCallObservable] watchLatestValue:^(CallState* latestCall) {
if (latestCall == nil) return;
if (latestCall == nil){
DDLogError(@"Latest Call is nil.");
return;
}
InCallViewController *callViewController = [InCallViewController inCallViewControllerWithCallState:latestCall
andOptionallyKnownContact:[latestCall potentiallySpecifiedContact]];

View File

@ -11,6 +11,7 @@
return v;
}
+(Future*) failed:(id)value {
DDLogVerbose(@"Future failed: %@", value);
FutureSource* v = [FutureSource new];
[v trySetFailure:value];
return v;
@ -22,7 +23,6 @@
}];
}
-(void) finallyDo:(void(^)(Future* completed))callback {
require(callback != nil);
@synchronized(self) {

View File

@ -83,6 +83,8 @@
return oldValue;
}
DDLogInfo(@"A new %@ key of sie %lu has been generated.", key, (unsigned long)length);
return [CryptoTools generateSecureRandomData:length];
}];
}
@ -116,6 +118,7 @@
}
-(void) setLocalNumberTo:(PhoneNumber*)localNumber {
require(localNumber != nil);
require([localNumber toE164]!= nil);
[self setValueForKey:LOCAL_NUMBER_KEY toValue:[localNumber toE164]];
}

View File

@ -56,6 +56,7 @@
@synchronized(self) {
if (value == nil) {
[dictionary removeObjectForKey:key];
DDLogWarn(@"Removing object for key: %@ ", key);
} else {
[dictionary setObject:value forKey:key];
}
@ -80,11 +81,14 @@
@synchronized(self) {
if (value == nil) {
[UICKeyChainStore removeItemForKey:key];
DDLogWarn(@"Removing object for key: %@", key);
} else {
if ([value isKindOfClass:[NSData class]]) {
[UICKeyChainStore setData:value forKey:key];
} else if ([value isKindOfClass:[NSString class]]){
[UICKeyChainStore setString:value forKey:key];
} else{
DDLogError(@"Unexpected class stored in the Keychain.");
}
}
}

View File

@ -6,6 +6,7 @@
#define IV_LENGTH 16
@implementation SrtpStream
+(SrtpStream*) srtpStreamWithCipherKey:(NSData*)cipherKey andMacKey:(NSData*)macKey andCipherIvSalt:(NSData*)cipherIvSalt {
require(cipherKey != nil);
require(macKey != nil);

View File

@ -44,9 +44,11 @@ static NSString *const RPDefaultsKeyPhoneNumberCanonical = @"RPDefaultsKeyPhoneN
+(PhoneNumber*) phoneNumberFromE164:(NSString*)text {
require(text != nil);
checkOperation([text hasPrefix:COUNTRY_CODE_PREFIX]);
PhoneNumber *number = [PhoneNumber phoneNumberFromText:text
andRegion:@"ZZ"];
return [PhoneNumber phoneNumberFromText:text
andRegion:@"ZZ"];
checkOperation(number != nil);
return number;
}
+(NSString*) bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:(NSString*)input {
@ -84,6 +86,7 @@ static NSString *const RPDefaultsKeyPhoneNumberCanonical = @"RPDefaultsKeyPhoneN
@try {
return [self phoneNumberFromText:text andRegion:regionCode];
} @catch (OperationFailed* ex) {
DDLogError(@"Error parsing phone number from region code");
return nil;
}
}

View File

@ -91,6 +91,7 @@
NSData* includedMac = [data takeLast:HMAC_TRUNCATED_SIZE];
NSData* payload = [data skipLast:HMAC_TRUNCATED_SIZE];
NSData* signalingMacKey = [[Environment preferences] getOrGenerateSignalingMacKey];
require(signalingMacKey != nil);
NSData* computedMac = [[payload hmacWithSha1WithKey:signalingMacKey] takeLast:HMAC_TRUNCATED_SIZE];
checkOperation([includedMac isEqualToData_TimingSafe:computedMac]);
return payload;

View File

@ -97,6 +97,8 @@
NSString* query = [NSString stringWithFormat:@"/apn/%@", [deviceToken encodedAsHexString]];
DDLogInfo(@"Registered APN Device Token with Signal Server");
return [HttpRequest httpRequestWithBasicAuthenticationAndMethod:@"PUT"
andLocation:query];
}

View File

@ -142,15 +142,17 @@
}];
Future *futureApnToRegister = [futurePhoneRegistrationVerified then:^(HttpResponse* okResponse) {
// @todo: keep handling code for simulator?
return [futureApnId catch:^id(id error) {
DDLogError(@"Could not get APN. Runs in Simulator?");
return nil;
}];
}];
return [futureApnToRegister then:^Future*(NSData* deviceToken) {
// @todo: distinguish between simulator no-apn error and other no-apn errors
if (deviceToken == nil) return futureApnToRegister;
if (deviceToken == nil){
DDLogError(@"Couldn't get a device token for APN. Runs in Simulator?");
return futureApnToRegister;
}
HttpRequest* request = [HttpRequest httpRequestToRegisterForApnSignalingWithDeviceToken:deviceToken];
return [HttpManager asyncOkResponseFromMasterServer:request