Skip to content

Commit

Permalink
Merge pull request #836 from monal-im/beta
Browse files Browse the repository at this point in the history
Stable 5.2.0
  • Loading branch information
FriedrichAltheide authored Jul 2, 2022
2 parents fe70f20 + 26a9c87 commit 6f6b006
Show file tree
Hide file tree
Showing 58 changed files with 1,132 additions and 979 deletions.
31 changes: 27 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,39 @@
.DS_Store

# Xcode
Monal/Monal.xcodeproj/project.xcworkspace/xcuserdata/anurodhp.xcuserdatad/UserInterfaceState.xcuserstate
Monal/Monal.xcodeproj/xcuserdata/anurodhp.xcuserdatad/xcschemes/Monal.xcscheme
Monal/Monal.xcodeproj/xcuserdata/anurodhp.xcuserdatad/xcschemes/jrtplib-static.xcscheme
Monal/Monal.xcodeproj/xcuserdata/anurodhp.xcuserdatad/xcschemes/xcschememanagement.plist
Monal/Monal.xcodeproj/xcuserdata/*
Monal/Monal.xcodeproj/project.xcworkspace/xcshareddata/*
Monal/Monal.xcodeproj/project.xcworkspace/xcuserdata/*
contents.xcworkspacedata
._*
*.xcscmblueprint
*.xccheckout
Monal/Monal.xcworkspace/xcshareddata/*
Monal/Monal.xcworkspace/xcuserdata/*

Monal/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
profile
*.moved-aside
DerivedData


# Pods
Monal/Pods

#Don't accidentally commit localization state
Monal/localization/external
Monal/localization/external/*
Monal/shareSheet-iOS/localization/external
Monal/shareSheet-iOS/localization/external/*

# certs and other encrypted stuff
*.pem
*.key
Expand Down
19 changes: 0 additions & 19 deletions Monal/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion Monal/Classes/ActiveChatsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
-(void) showSettings;
-(void) showPrivacySettings;
-(void) showDetails;
-(void) showRegisterWithUsername:(NSString*) username onHost:(NSString*) host withToken:(NSString* _Nullable) token usingCompletion:(monal_void_block_t) completion;
-(void) showRegisterWithUsername:(NSString*) username onHost:(NSString*) host withToken:(NSString* _Nullable) token usingCompletion:(monal_void_block_t _Nullable) callback;

@end

Expand Down
7 changes: 4 additions & 3 deletions Monal/Classes/ActiveChatsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -722,17 +722,18 @@ -(void) showContacts
[self performSegueWithIdentifier:@"showContacts" sender:self];
}

-(void) showRegisterWithUsername:(NSString*) username onHost:(NSString*) host withToken:(NSString*) token usingCompletion:(monal_void_block_t) completion
//we can not call this var "completion" because then some dumb comiler check kicks in and tells us "completion handler is never called" which ich plainly wrong
//callback doesn't seem to be a word in the objc compiler's "bad words" dictionary, so this makes it compile again
-(void) showRegisterWithUsername:(NSString*) username onHost:(NSString*) host withToken:(NSString*) token usingCompletion:(monal_void_block_t) callback
{
MonalAppDelegate* appDelegate = (MonalAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.window.rootViewController dismissViewControllerAnimated:YES completion:^{
[self performSegueWithIdentifier:@"showRegister" sender:@{
@"host": nilWrapper(host),
@"username": nilWrapper(username),
@"token": nilWrapper(token),
@"completion": nilDefault(completion, ^{}),
@"completion": nilDefault(callback, ^{}),
}];
completion();
}];
}

Expand Down
6 changes: 6 additions & 0 deletions Monal/Classes/DataLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ extern NSString* const kMessageTypeFiletransfer;
-(void) upgradeImageMessagesToFiletransferMessages;

-(void) invalidateAllAccountStates;

-(NSString*) lastUsedPushServerForAccount:(NSNumber*) accountNo;
-(void) updateUsedPushServer:(NSString*) pushServer forAccount:(NSNumber*) accountNo;



-(void) deleteDelayedMessageStanzasForAccount:(NSNumber*) accountNo;
-(void) addDelayedMessageStanza:(MLXMLNode*) stanza forArchiveJid:(NSString*) archiveJid andAccountNo:(NSNumber*) accountNo;
-(MLXMLNode* _Nullable) getNextDelayedMessageStanzaForArchiveJid:(NSString*) archiveJid andAccountNo:(NSNumber*) accountNo;
Expand Down
14 changes: 14 additions & 0 deletions Monal/Classes/DataLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,20 @@ -(void) invalidateAllAccountStates
#endif
}

-(NSString*) lastUsedPushServerForAccount:(NSNumber*) accountNo
{
return [self.db idReadTransaction:^{
return [self.db executeScalar:@"SELECT registeredPushServer FROM account WHERE account_id=?;" andArguments:@[accountNo]];
}];
}

-(void) updateUsedPushServer:(NSString*) pushServer forAccount:(NSNumber*) accountNo
{
[self.db voidWriteTransaction:^{
[self.db executeScalarReader:@"UPDATE account SET registeredPushServer=? WHERE account_id=?;" andArguments:@[pushServer, accountNo]];
}];
}

-(void) version
{
// checking db version and upgrading if necessary
Expand Down
36 changes: 35 additions & 1 deletion Monal/Classes/DataLayerMigrations.m
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,41 @@ ROWID IN ( \
}];

[self updateDB:db withDataLayer:dataLayer toVersion:5.120 withBlock:^{
//dummy upgrade to make sure all state gets invalidatet because of new MLHandler behaviour (mandatory arguments)
//dummy upgrade to make sure all state gets invalidated because of new MLHandler behaviour (mandatory arguments)
}];

// add push server column to accounts
[self updateDB:db withDataLayer:dataLayer toVersion:5.201 withBlock:^{
[db executeNonQuery:@"ALTER TABLE account ADD COLUMN registeredPushServer TEXT DEFAULT NULL;"];
#ifdef IS_ALPHA
NSString* currentPushserver = @"push.molitor-dietzel.de";
#else
NSString* currentPushserver = @"ios13push.monal.im";
#endif
[db executeNonQuery:@"UPDATE account SET registeredPushServer=?;" andArguments:@[currentPushserver]];
}];

[self updateDB:db withDataLayer:dataLayer toVersion:5.202 withBlock:^{
//dummy upgrade to make sure all state gets invalidated because of new mandatory {MLFiletransfer, handleHardlinking} arguments
}];

[self updateDB:db withDataLayer:dataLayer toVersion:5.203 withBlock:^{
// ensure that we TOFU trust our own device ids
[db executeNonQuery:@"UPDATE signalContactIdentity \
SET trustLevel=1 \
WHERE \
ROWID IN ( \
SELECT sci.ROWID \
FROM account as a \
INNER JOIN signalIdentity as si \
ON a.account_id = si.account_id \
INNER JOIN signalContactIdentity as sci \
ON sci.account_id = a.account_id \
AND si.deviceid = sci.contactDeviceId \
WHERE \
sci.trustLevel = 0 \
) \
;"];
}];

// check if db version changed
Expand Down
6 changes: 5 additions & 1 deletion Monal/Classes/HelperTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ void logException(NSException* exception);
+(void) MLAssert:(BOOL) check withText:(NSString*) text andUserData:(id _Nullable) additionalData andFile:(char*) file andLine:(int) line andFunc:(char*) func;
+(void) postError:(NSString*) description withNode:(XMPPStanza* _Nullable) node andAccount:(xmpp*) account andIsSevere:(BOOL) isSevere;
+(NSString*) extractXMPPError:(XMPPStanza*) stanza withDescription:(NSString* _Nullable) description;
+(NSString*) pushServer;

+(NSDictionary<NSString*, NSString*>*) getInvalidPushServers;
+(NSString*) getSelectedPushServerBasedOnLocale;
+(NSDictionary<NSString*, NSString*>*) getAvailablePushServers;

+(NSData*) serializeObject:(id) obj;
+(id) unserializeData:(NSData*) data;
Expand All @@ -41,6 +44,7 @@ void logException(NSException* exception);
+(UIColor*) generateColorFromJid:(NSString*) jid;
+(NSString*) bytesToHuman:(int64_t) bytes;
+(NSString*) stringFromToken:(NSData*) tokenIn;
+(void) configureFileProtection:(NSString*) protectionLevel forFile:(NSString*) file;
+(void) configureFileProtectionFor:(NSString*) file;
+(NSDictionary<NSString*, NSString*>*) splitJid:(NSString*) jid;
+(void) clearSyncErrorsOnAppForeground;
Expand Down
46 changes: 41 additions & 5 deletions Monal/Classes/HelperTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ +(void) MLAssert:(BOOL) check withText:(NSString*) text andUserData:(id) userInf
if([filePathComponents count]>1)
fileStr = [NSString stringWithFormat:@"%@/%@", filePathComponents[[filePathComponents count]-2], filePathComponents[[filePathComponents count]-1]];
DDLogError(@"Assertion triggered at %@:%d in %s", fileStr, line, func);
@throw [NSException exceptionWithName:[NSString stringWithFormat:@"MLAssert triggered at %@:%d in %s", fileStr, line, func] reason:text userInfo:userInfo];
@throw [NSException exceptionWithName:[NSString stringWithFormat:@"MLAssert triggered at %@:%d in %s with reason '%@' and userInfo: %@", fileStr, line, func, text, userInfo] reason:text userInfo:userInfo];
}
}

Expand All @@ -88,15 +88,46 @@ +(NSString*) extractXMPPError:(XMPPStanza*) stanza withDescription:(NSString*) d
return message;
}

+(NSString*) pushServer
+(NSDictionary<NSString*, NSString*>*) getInvalidPushServers
{
return @{
@"ios13push.monal.im": [[[UIDevice currentDevice] identifierForVendor] UUIDString],
@"push.monal.im": [[[UIDevice currentDevice] identifierForVendor] UUIDString],
};
}

+(NSString*) getSelectedPushServerBasedOnLocale
{
#ifdef IS_ALPHA
return @"alpha.push.monal-im.org";
#else
return @"ios13push.monal.im";
if([[[NSLocale currentLocale] countryCode] isEqualToString:@"US"])
{
return @"us.prod.push.monal-im.org";
}
else
{
return @"eu.prod.push.monal-im.org";
}
#endif
}

+(NSDictionary<NSString*, NSString*>*) getAvailablePushServers
{
#ifdef IS_ALPHA
return @{
@"alpha.push.monal-im.org": @"Europe - Alpha",
@"alpha2.push.monal-im.org": @"Disabled - Alpha Test",
};
#else
return @{
@"us.prod.push.monal-im.org": @"US",
@"eu.prod.push.monal-im.org": @"Europe",
};
#endif
}

// on push

+(NSData*) serializeObject:(id) obj
{
Expand Down Expand Up @@ -334,15 +365,15 @@ +(NSString*) stringFromToken:(NSData*) tokenIn
return token;
}

+(void) configureFileProtectionFor:(NSString*) file
+(void) configureFileProtection:(NSString*) protectionLevel forFile:(NSString*) file
{
#if TARGET_OS_IPHONE
NSFileManager* fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath:file])
{
//DDLogVerbose(@"protecting file '%@'...", file);
NSError* error;
[fileManager setAttributes:@{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication} ofItemAtPath:file error:&error];
[fileManager setAttributes:@{NSFileProtectionKey: protectionLevel} ofItemAtPath:file error:&error];
if(error)
{
DDLogError(@"Error configuring file protection level for: %@", file);
Expand All @@ -356,6 +387,11 @@ +(void) configureFileProtectionFor:(NSString*) file
#endif
}

+(void) configureFileProtectionFor:(NSString*) file
{
[self configureFileProtection:NSFileProtectionCompleteUntilFirstUserAuthentication forFile:file];
}

+(NSDictionary<NSString*, NSString*>*) splitJid:(NSString*) jid
{
//cache results
Expand Down
8 changes: 4 additions & 4 deletions Monal/Classes/MLAudioRecoderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ NS_ASSUME_NONNULL_BEGIN

@protocol AudioRecoderManagerDelegate

-(void)notifyResult:(BOOL)isSuccess error:(NSString* _Nullable)errorMsg;
-(void)notifyStart;
-(void)notifyStop:(NSURL*)fileURL;
-(void)updateCurrentTime:(NSTimeInterval) audioDuration;
-(void) notifyResult:(BOOL) isSuccess error:(NSString* _Nullable) errorMsg;
-(void) notifyStart;
-(void) notifyStop:(NSURL*) fileURL;
-(void) updateCurrentTime:(NSTimeInterval) audioDuration;
@end

@interface MLAudioRecoderManager : NSObject <AVAudioRecorderDelegate>
Expand Down
3 changes: 2 additions & 1 deletion Monal/Classes/MLAudioRecoderManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ -(void) start
updateTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimeInfo) userInfo:nil repeats:YES];
}

-(void)stop{
-(void) stop
{
[self.audioRecorder stop];

[updateTimer invalidate];
Expand Down
8 changes: 7 additions & 1 deletion Monal/Classes/MLContact.m
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,13 @@ -(NSString*) contactDisplayNameWithFallback:(NSString* _Nullable) fallbackName;
displayName = fallbackName;
}
DDLogVerbose(@"Calculated contactDisplayName for '%@': %@", self.contactJid, displayName);
return nilDefault(displayName, @"");
MLAssert(displayName != nil, @"Display name should never be nil!", (@{
@"jid": nilWrapper(self.contactJid),
@"nickName": nilWrapper(self.nickName),
@"fullName": nilWrapper(self.fullName),
@"fallbackName": nilWrapper(fallbackName)
}));
return displayName;
}

-(NSString*) contactDisplayName
Expand Down
1 change: 1 addition & 0 deletions Monal/Classes/MLFiletransfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
+(MLHandler*) prepareUIImageUpload:(UIImage*) image;
+(void) uploadFile:(NSURL*) fileUrl onAccount:(xmpp*) account withEncryption:(BOOL) encrypted andCompletion:(void (^)(NSString* _Nullable url, NSString* _Nullable mimeType, NSNumber* _Nullable size, NSError* _Nullable error)) completion;
+(void) uploadUIImage:(UIImage*) image onAccount:(xmpp*) account withEncryption:(BOOL) encrypted andCompletion:(void (^)(NSString* _Nullable url, NSString* _Nullable mimeType, NSNumber* _Nullable size, NSError* _Nullable error)) completion;
+(void) hardlinkFileForMessage:(MLMessage*) msg;
+(BOOL) isFileforHistoryIdInTransfer:(NSNumber*) historyId;
+(NSString*) getMimeTypeOfOriginalFile:(NSString*) file;

Expand Down
Loading

0 comments on commit 6f6b006

Please sign in to comment.