Skip to content

Commit

Permalink
Merge pull request #831 from monal-im/develop
Browse files Browse the repository at this point in the history
5.2.0b1-1.0
  • Loading branch information
FriedrichAltheide authored Jun 18, 2022
2 parents d80d87a + 26e5dfb commit 3edf484
Show file tree
Hide file tree
Showing 28 changed files with 728 additions and 570 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ contents.xcworkspacedata
# Pods
Monal/Pods

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

# certs and other encrypted stuff
*.pem
*.key
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
17 changes: 16 additions & 1 deletion Monal/Classes/DataLayerMigrations.m
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,22 @@ 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
}];

// 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
44 changes: 40 additions & 4 deletions Monal/Classes/HelperTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 3edf484

Please sign in to comment.