Skip to content

Commit

Permalink
6.0.4 (#989)
Browse files Browse the repository at this point in the history
- Fix pipelining bug when briefly turning off SASL2
- Show server software and version in server details
  • Loading branch information
tmolitor-stud-tu authored Jan 6, 2024
2 parents 6fb449a + 54bd8fb commit f3b30b0
Show file tree
Hide file tree
Showing 18 changed files with 782 additions and 64 deletions.
1 change: 1 addition & 0 deletions Monal/Classes/ActiveChatsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ -(void) presentChatWithContact:(MLContact*) contact

-(void) presentChatWithContact:(MLContact*) contact andCompletion:(monal_id_block_t _Nullable) completion
{
DDLogVerbose(@"presenting chat with contact: %@, stacktrace: %@", contact, [NSThread callStackSymbols]);
dispatch_async(dispatch_get_main_queue(), ^{
DDLogVerbose(@"presenting chat with contact: %@", contact);
[self dismissCompleteViewChainWithAnimation:YES andCompletion:^{
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/ContactResources.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct ContactResources: View {
if softwareInfo.fromJid == contact.obj.contactJid && xmppAccount.accountNo == contact.obj.accountId {
DispatchQueue.main.async {
DDLogVerbose("Successfully matched software version info update to current contact: \(contact.obj)")
self.contactVersionInfos[softwareInfo.resource] = ObservableKVOWrapper<MLContactSoftwareVersionInfo>(softwareInfo)
self.contactVersionInfos[softwareInfo.resource ?? ""] = ObservableKVOWrapper<MLContactSoftwareVersionInfo>(softwareInfo)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions Monal/Classes/DataLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ -(void) setResourceOnline:(XMPPPresence*) presenceObj forAccount:(NSNumber*) acc
}];
}

-(MLContactSoftwareVersionInfo* _Nullable) getSoftwareVersionInfoForContact:(NSString*)contact resource:(NSString*)resource andAccount:(NSNumber*)accountNo
-(MLContactSoftwareVersionInfo* _Nullable) getSoftwareVersionInfoForContact:(NSString*) contact resource:(NSString*) resource andAccount:(NSNumber*) accountNo
{
if(accountNo == nil)
return nil;
Expand All @@ -668,14 +668,14 @@ -(MLContactSoftwareVersionInfo* _Nullable) getSoftwareVersionInfoForContact:(NSS
}
}

-(void) setSoftwareVersionInfoForContact:(NSString*)contact
resource:(NSString*)resource
andAccount:(NSNumber*)account
-(void) setSoftwareVersionInfoForContact:(NSString*) contact
resource:(NSString*) resource
andAccount:(NSNumber*) account
withSoftwareInfo:(MLContactSoftwareVersionInfo*) newSoftwareInfo
{
[self.db voidWriteTransaction:^{
NSString* query = @"update buddy_resources set platform_App_Name=?, platform_App_Version=?, platform_OS=? where buddy_id in (select buddy_id from buddylist where account_id=? and buddy_name=?) and resource=?";
NSArray* params = @[newSoftwareInfo.appName, newSoftwareInfo.appVersion, newSoftwareInfo.platformOs, account, contact, resource];
NSArray* params = @[nilWrapper(newSoftwareInfo.appName), nilWrapper(newSoftwareInfo.appVersion), nilWrapper(newSoftwareInfo.platformOs), account, contact, resource];
[self.db executeNonQuery:query andArguments:params];
}];
}
Expand Down
2 changes: 2 additions & 0 deletions Monal/Classes/HelperTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#import "MLUDPLogger.h"
#import "MLStreamRedirect.h"
#import "commithash.h"
#import "MLContactSoftwareVersionInfo.h"

@import UserNotifications;
@import CoreImage;
Expand Down Expand Up @@ -643,6 +644,7 @@ +(id) unserializeData:(NSData*) data
[MLMessage class],
[NSURL class],
[OmemoState class],
[MLContactSoftwareVersionInfo class],
]] fromData:data error:&error];
if(error)
@throw [NSException exceptionWithName:@"NSError" reason:[NSString stringWithFormat:@"%@", error] userInfo:@{@"error": error}];
Expand Down
7 changes: 4 additions & 3 deletions Monal/Classes/MLContactSoftwareVersionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@

NS_ASSUME_NONNULL_BEGIN

@interface MLContactSoftwareVersionInfo : NSObject
@interface MLContactSoftwareVersionInfo : NSObject <NSSecureCoding>

@property (nonatomic, copy) NSString* fromJid;
@property (nonatomic, copy) NSString* resource;
@property (nonatomic, copy) NSString* _Nullable resource;
@property (nonatomic, copy) NSString* _Nullable appName;
@property (nonatomic, copy) NSString* _Nullable appVersion;
@property (nonatomic, copy) NSString* _Nullable platformOs;
@property (nonatomic, copy) NSDate* _Nullable lastInteraction;

-(instancetype) initWithJid:(NSString*) jid andRessource:(NSString*) resource andAppName:(NSString* _Nullable) appName andAppVersion:(NSString* _Nullable) appVersion andPlatformOS:(NSString* _Nullable) platformOs andLastInteraction:(NSDate* _Nullable) lastInteraction;
+(BOOL) supportsSecureCoding;
-(instancetype) initWithJid:(NSString*) jid andRessource:(NSString* _Nullable) resource andAppName:(NSString* _Nullable) appName andAppVersion:(NSString* _Nullable) appVersion andPlatformOS:(NSString* _Nullable) platformOs andLastInteraction:(NSDate* _Nullable) lastInteraction;
-(BOOL) isEqual:(id _Nullable) object;
-(NSUInteger) hash;

Expand Down
31 changes: 30 additions & 1 deletion Monal/Classes/MLContactSoftwareVersionInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ @interface MLContactSoftwareVersionInfo ()

@implementation MLContactSoftwareVersionInfo

-(instancetype) initWithJid:(NSString*) jid andRessource:(NSString*) resource andAppName:(NSString* _Nullable) appName andAppVersion:(NSString* _Nullable) appVersion andPlatformOS:(NSString* _Nullable) platformOs andLastInteraction:(NSDate* _Nullable) lastInteraction
+(BOOL) supportsSecureCoding
{
return YES;
}

-(instancetype) initWithJid:(NSString*) jid andRessource:(NSString* _Nullable) resource andAppName:(NSString* _Nullable) appName andAppVersion:(NSString* _Nullable) appVersion andPlatformOS:(NSString* _Nullable) platformOs andLastInteraction:(NSDate* _Nullable) lastInteraction
{
self = [super init];
self.fromJid = jid;
Expand All @@ -26,6 +31,28 @@ -(instancetype) initWithJid:(NSString*) jid andRessource:(NSString*) resource an
return self;
}

-(void) encodeWithCoder:(NSCoder*) coder
{
[coder encodeObject:self.fromJid forKey:@"fromJid"];
[coder encodeObject:self.resource forKey:@"resource"];
[coder encodeObject:self.appName forKey:@"appName"];
[coder encodeObject:self.appVersion forKey:@"appVersion"];
[coder encodeObject:self.platformOs forKey:@"platformOs"];
[coder encodeObject:self.lastInteraction forKey:@"lastInteraction"];
}

-(instancetype) initWithCoder:(NSCoder*) coder
{
self = [self init];
self.fromJid = [coder decodeObjectForKey:@"fromJid"];
self.resource = [coder decodeObjectForKey:@"resource"];
self.appName = [coder decodeObjectForKey:@"appName"];
self.appVersion = [coder decodeObjectForKey:@"appVersion"];
self.platformOs = [coder decodeObjectForKey:@"platformOs"];
self.lastInteraction = [coder decodeObjectForKey:@"lastInteraction"];
return self;
}

-(BOOL) isEqual:(id _Nullable) object
{
if(object == nil || self == object)
Expand All @@ -43,6 +70,8 @@ -(NSUInteger) hash

-(NSString*) id
{
if(self.resource == nil)
return [NSString stringWithFormat:@"%@", self.fromJid];
return [NSString stringWithFormat:@"%@/%@", self.fromJid, self.resource];
}

Expand Down
44 changes: 18 additions & 26 deletions Monal/Classes/MLIQProcessor.m
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ +(BOOL) processRosterWithAccount:(xmpp*) account andIqNode:(XMPPIQ*) iqNode
}

if(!account.connectionProperties.conferenceServer && [features containsObject:@"http://jabber.org/protocol/muc"])
account.connectionProperties.conferenceServer = iqNode.from;
account.connectionProperties.conferenceServer = iqNode.fromUser;
$$

$$class_handler(handleServerDiscoItems, $$ID(xmpp*, account), $$ID(XMPPIQ*, iqNode))
Expand Down Expand Up @@ -708,35 +708,27 @@ +(BOOL) processRosterWithAccount:(xmpp*) account andIqNode:(XMPPIQ*) iqNode
+(void) iqVersionResult:(XMPPIQ*) iqNode forAccount:(xmpp*) account
{
NSString* iqAppName = [iqNode findFirst:@"{jabber:iq:version}query/name#"];
if(!iqAppName)
iqAppName = @"";
NSString* iqAppVersion = [iqNode findFirst:@"{jabber:iq:version}query/version#"];
if(!iqAppVersion)
iqAppVersion = @"";
NSString* iqPlatformOS = [iqNode findFirst:@"{jabber:iq:version}query/os#"];
if(!iqPlatformOS)
iqPlatformOS = @"";

MLContactSoftwareVersionInfo* versionDBInfo = [[DataLayer sharedInstance] getSoftwareVersionInfoForContact:iqNode.fromUser resource:iqNode.fromResource andAccount:account.accountNo];

if(versionDBInfo == nil || !(
[versionDBInfo.appName isEqualToString:iqAppName] &&
[versionDBInfo.appVersion isEqualToString:iqAppVersion] &&
[versionDBInfo.platformOs isEqualToString:iqPlatformOS]
)) {
DDLogVerbose(@"Updating software version info for %@", iqNode.from);
NSDate* lastInteraction = [[DataLayer sharedInstance] lastInteractionOfJid:iqNode.fromUser andResource:iqNode.fromResource forAccountNo:account.accountNo];
MLContactSoftwareVersionInfo* newSoftwareVersionInfo = [[MLContactSoftwareVersionInfo alloc] initWithJid:iqNode.fromUser andRessource:iqNode.fromResource andAppName:iqAppName andAppVersion:iqAppVersion andPlatformOS:iqPlatformOS andLastInteraction:lastInteraction];

[[DataLayer sharedInstance] setSoftwareVersionInfoForContact:iqNode.fromUser
resource:iqNode.fromResource
andAccount:account.accountNo
withSoftwareInfo:newSoftwareVersionInfo];

[[MLNotificationQueue currentQueue] postNotificationName:kMonalXmppUserSoftWareVersionRefresh
object:account
userInfo:@{@"versionInfo": newSoftwareVersionInfo}];
if([iqNode.fromUser isEqualToString:account.connectionProperties.identity.domain])
{
account.connectionProperties.serverVersion = [[MLContactSoftwareVersionInfo alloc] initWithJid:iqNode.fromUser andRessource:iqNode.fromResource andAppName:iqAppName andAppVersion:iqAppVersion andPlatformOS:iqPlatformOS andLastInteraction:[NSDate date]];
return;
}

DDLogVerbose(@"Updating software version info for %@", iqNode.from);
NSDate* lastInteraction = [[DataLayer sharedInstance] lastInteractionOfJid:iqNode.fromUser andResource:iqNode.fromResource forAccountNo:account.accountNo];
MLContactSoftwareVersionInfo* newSoftwareVersionInfo = [[MLContactSoftwareVersionInfo alloc] initWithJid:iqNode.fromUser andRessource:iqNode.fromResource andAppName:iqAppName andAppVersion:iqAppVersion andPlatformOS:iqPlatformOS andLastInteraction:lastInteraction];

[[DataLayer sharedInstance] setSoftwareVersionInfoForContact:iqNode.fromUser
resource:iqNode.fromResource
andAccount:account.accountNo
withSoftwareInfo:newSoftwareVersionInfo];

[[MLNotificationQueue currentQueue] postNotificationName:kMonalXmppUserSoftWareVersionRefresh
object:account
userInfo:@{@"versionInfo": newSoftwareVersionInfo}];
}

+(void) respondWithErrorTo:(XMPPIQ*) iqNode onAccount:(xmpp*) account
Expand Down
9 changes: 8 additions & 1 deletion Monal/Classes/MLMucProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ NS_ASSUME_NONNULL_BEGIN

-(void) join:(NSString*) room;
-(void) leave:(NSString*) room withBookmarksUpdate:(BOOL) updateBookmarks;
-(void) publishAvatar:(UIImage*) image forMuc:(NSString*) room;

//muc management methods
-(NSString* _Nullable) createGroup:(NSString*) node;
-(void) changeNameOfMuc:(NSString*) room to:(NSString*) name;
-(void) changeSubjectOfMuc:(NSString*) room to:(NSString*) subject;
-(void) publishAvatar:(UIImage* _Nullable) image forMuc:(NSString*) room;
-(void) setAffiliation:(NSString*) affiliation ofUser:(NSString*) jid inMuc:(NSString*) roomJid;

-(void) pingAllMucs;
-(void) ping:(NSString*) roomJid;
-(BOOL) checkIfStillBookmarked:(NSString*) room;
Expand Down
Loading

0 comments on commit f3b30b0

Please sign in to comment.