Skip to content

Commit

Permalink
Merge pull request #962 from monal-im/6.0rc2
Browse files Browse the repository at this point in the history
Small improvements and bugfixes
  • Loading branch information
FriedrichAltheide authored Oct 16, 2023
2 parents 47a8f97 + dc54e57 commit ec9f431
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Monal/Classes/BackgroundSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ struct BackgroundSettings: View {
}
}
}
.navigationBarTitle(contact != nil ? Text("Contact Background") : Text("Default Background"))
.navigationBarTitle(contact != nil ? Text("Chat Background") : Text("Default Background"))
.onChange(of:inputImage) { _ in
MLImageManager.sharedInstance().saveBackgroundImageData(inputImage?.pngData(), for:self.contact?.obj)
}
Expand Down
13 changes: 5 additions & 8 deletions Monal/Classes/ContactDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,15 @@ struct ContactDetails: View {
if(contact.isMuted) {
Image(systemName: "bell.slash.fill")
.foregroundColor(.red)
Text("Contact is muted")
.foregroundColor(.accentColor)
contact.isGroup ? Text("Notifications disabled") : Text("Contact is muted")
} else if(contact.isGroup && contact.isMentionOnly) {
Image(systemName: "bell.badge")
.foregroundColor(.accentColor)
Text("Group/Channel is mention only")
.foregroundColor(.accentColor)
Text("Notify only when mentioned")
} else {
Image(systemName: "bell.fill")
.foregroundColor(.green)
Text("Contact is not muted")
.foregroundColor(.accentColor)
contact.isGroup ? Text("Notify on all messages") : Text("Contact is not muted")
}
}
}
Expand Down Expand Up @@ -115,7 +112,7 @@ struct ContactDetails: View {
#endif

if(!contact.isGroup && !contact.isSelfChat) {
TextField("Change Nickname", text: $contact.nickNameView)
TextField("Rename Contact", text: $contact.nickNameView)
.textFieldStyle(RoundedBorderTextFieldStyle())
.addClearButton(text:$contact.nickNameView)
}
Expand Down Expand Up @@ -157,7 +154,7 @@ struct ContactDetails: View {
}

NavigationLink(destination: LazyClosureView(BackgroundSettings(contact:contact, delegate:delegate))) {
Text("Change Contact Background")
Text("Change Chat Background")
}
}
.listStyle(.plain)
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/ContactDetailsHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct ContactDetailsHeader: View {
Spacer()
Image(uiImage: contact.avatar)
.resizable()
.frame(minWidth: 100, idealWidth: 150, maxWidth: 200, minHeight: 100, idealHeight: 150, maxHeight: 200, alignment: .center)
.frame(width: 150, height: 150, alignment: .center)
.scaledToFit()
.shadow(radius: 7)
Spacer()
Expand Down
7 changes: 5 additions & 2 deletions Monal/Classes/MLIQProcessor.m
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ +(BOOL) processRosterWithAccount:(xmpp*) account andIqNode:(XMPPIQ*) iqNode
if([features containsObject:@"urn:xmpp:ping"])
account.connectionProperties.supportsPing = YES;

if([features containsObject:@"urn:xmpp:extdisco:2"])
account.connectionProperties.supportsExternalServiceDiscovery = YES;

if([features containsObject:@"urn:xmpp:blocking"])
{
account.connectionProperties.supportsBlocking = YES;
Expand All @@ -537,7 +540,7 @@ +(BOOL) processRosterWithAccount:(xmpp*) account andIqNode:(XMPPIQ*) iqNode
DDLogInfo(@"supports http upload with server: %@", iqNode.from);
account.connectionProperties.supportsHTTPUpload = YES;
account.connectionProperties.uploadServer = iqNode.from;
account.connectionProperties.uploadSize = [[iqNode findFirst:@"{http://jabber.org/protocol/disco#info}query/\\{urn:xmpp:http:upload}result@max-file-size\\|int"] integerValue];
account.connectionProperties.uploadSize = [[iqNode findFirst:@"{http://jabber.org/protocol/disco#info}query/\\{urn:xmpp:http:upload:0}result@max-file-size\\|int"] integerValue];
DDLogInfo(@"Upload max filesize: %lu", account.connectionProperties.uploadSize);
}
$$
Expand All @@ -550,7 +553,7 @@ +(BOOL) processRosterWithAccount:(xmpp*) account andIqNode:(XMPPIQ*) iqNode
DDLogInfo(@"supports http upload with server: %@", iqNode.from);
account.connectionProperties.supportsHTTPUpload = YES;
account.connectionProperties.uploadServer = iqNode.from;
account.connectionProperties.uploadSize = [[iqNode findFirst:@"{http://jabber.org/protocol/disco#info}query/\\{urn:xmpp:http:upload}result@max-file-size\\|int"] integerValue];
account.connectionProperties.uploadSize = [[iqNode findFirst:@"{http://jabber.org/protocol/disco#info}query/\\{urn:xmpp:http:upload:0}result@max-file-size\\|int"] integerValue];
DDLogInfo(@"Upload max filesize: %lu", account.connectionProperties.uploadSize);
}

Expand Down
12 changes: 11 additions & 1 deletion Monal/Classes/MLImageManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "MLImageManager.h"
#import "MLXMPPManager.h"
#import "HelperTools.h"
#import "DataLayer.h"
#import "AESGcm.h"
Expand Down Expand Up @@ -180,7 +181,16 @@ -(UIImage*) outboundImage

-(UIImage*) generateDummyIconForContact:(MLContact*) contact
{
NSString* contactLetter = [[[contact contactDisplayName] substringToIndex:1] uppercaseString];
NSString* contactLetter;

if(contact.isSelfChat)
{
xmpp* account = [[MLXMPPManager sharedInstance] getConnectedAccountForID:contact.accountId];
contactLetter = [[[MLContact ownDisplayNameForAccount:account] substringToIndex:1] uppercaseString];
}
else
contactLetter = [[[contact contactDisplayName] substringToIndex:1] uppercaseString];

UIColor* background = [HelperTools generateColorFromJid:contact.contactJid];
UIColor* foreground = [UIColor blackColor];
if(![background isLightColor])
Expand Down
17 changes: 9 additions & 8 deletions Monal/Classes/MLMessageProcessor.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,17 @@ +(MLMessage* _Nullable) processMessage:(XMPPMessage*) messageNode andOuterMessag
DDLogVerbose(@"Not a carbon copy of a muc pm for contact: %@", carbonTestContact);
}

NSString* possibleUnkownContact;
if([messageNode.fromUser isEqualToString:account.connectionProperties.identity.jid])
possibleUnkownContact = messageNode.toUser;
else
possibleUnkownContact = messageNode.fromUser;

if(([messageNode check:@"/<type=groupchat>"] || [messageNode check:@"{http://jabber.org/protocol/muc#user}x"]) && ![messageNode check:@"{http://jabber.org/protocol/muc#user}x/invite"])
{
// Ignore all group chat msgs from unkown groups
if([[DataLayer sharedInstance] isContactInList:messageNode.fromUser forAccount:account.accountNo] == NO)
// Ignore all group chat msgs from unkown groups or 1:1 chats
MLContact* mucTestContact = [MLContact createContactFromJid:possibleUnkownContact andAccountNo:account.accountNo];
if([[DataLayer sharedInstance] isContactInList:messageNode.fromUser forAccount:account.accountNo] == NO || !mucTestContact.isGroup)
{
// ignore message
DDLogWarn(@"Ignoring groupchat message from %@", messageNode.toUser);
Expand All @@ -245,12 +252,6 @@ +(MLMessage* _Nullable) processMessage:(XMPPMessage*) messageNode andOuterMessag
}
else
{
NSString* possibleUnkownContact;
if([messageNode.fromUser isEqualToString:account.connectionProperties.identity.jid])
possibleUnkownContact = messageNode.toUser;
else
possibleUnkownContact = messageNode.fromUser;

// handle KeyTransportMessages directly without adding a 1:1 buddy
if([messageNode check:@"{eu.siacs.conversations.axolotl}encrypted/header"] == YES && [messageNode check:@"{eu.siacs.conversations.axolotl}encrypted/payload#"] == NO)
{
Expand Down
18 changes: 9 additions & 9 deletions Monal/Classes/MLServerDetails.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ - (void)didReceiveMemoryWarning {

-(void) checkServerCaps:(MLXMPPConnection*) connection
{
// supportsPubSub
[self.serverCaps addObject:@{
// see MLIQProcessor.m multiple xep required for pubsub
@"Title":NSLocalizedString(@"XEP-0163 Personal Eventing Protocol", @""),
@"Description":NSLocalizedString(@"This specification defines semantics for using the XMPP publish-subscribe protocol to broadcast state change events associated with an instant messaging and presence account.", @""),
@"Color": connection.supportsPubSub ? (connection.supportsModernPubSub ? @"Green" : @"Yellow") : @"Red"
}];

// supportsBlocking
[self.serverCaps addObject:@{
@"Title":NSLocalizedString(@"XEP-0191: Blocking Command", @""),
Expand All @@ -85,7 +93,7 @@ -(void) checkServerCaps:(MLXMPPConnection*) connection
[self.serverCaps addObject:@{
@"Title":NSLocalizedString(@"XEP-0215: External Service Discovery", @""),
@"Description":NSLocalizedString(@"XMPP protocol extension for discovering services external to the XMPP network, like STUN or TURN servers needed for A/V calls.", @""),
@"Color": connection.supportsPing ? @"Green" : @"Red"
@"Color": connection.supportsExternalServiceDiscovery ? @"Green" : @"Red"
}];

// supportsRosterVersion
Expand Down Expand Up @@ -137,14 +145,6 @@ -(void) checkServerCaps:(MLXMPPConnection*) connection
@"Color": connection.supportsRosterPreApproval ? @"Green" : @"Red"
}];

// supportsPubSub
[self.serverCaps addObject:@{
// see MLIQProcessor.m multiple xep required for pubsub
@"Title":NSLocalizedString(@"XEP-0163 Personal Eventing Protocol", @""),
@"Description":NSLocalizedString(@"This specification defines semantics for using the XMPP publish-subscribe protocol to broadcast state change events associated with an instant messaging and presence account.", @""),
@"Color": connection.supportsPubSub ? (connection.supportsModernPubSub ? @"Green" : @"Yellow") : @"Red"
}];

// supportsSSDP
[self.serverCaps addObject:@{
// see MLIQProcessor.m multiple xep required for pubsub
Expand Down
1 change: 1 addition & 0 deletions Monal/Classes/MLXMPPConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, assign) BOOL supportsBlocking;
@property (nonatomic, assign) BOOL supportsPing;
@property (nonatomic, assign) BOOL supportsExternalServiceDiscovery;
@property (nonatomic, assign) BOOL supportsPubSub;
@property (nonatomic, assign) BOOL supportsPubSubMax;
@property (nonatomic, assign) BOOL supportsModernPubSub;
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/chatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2335,7 +2335,7 @@ -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
if([info[@"mimeType"] hasPrefix:@"image/gif"])
animatedImageData = [NSData dataWithContentsOfFile:info[@"cacheFile"]];
UIViewController* imageViewer = [[SwiftuiInterface new] makeImageViewer:image withFilename:info[@"filename"] andAnimatedImageData:animatedImageData];
imageViewer.modalPresentationStyle = UIModalPresentationFullScreen;
imageViewer.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:imageViewer animated:YES completion:^{}];
});
}
Expand Down
8 changes: 8 additions & 0 deletions Monal/Classes/xmpp.m
Original file line number Diff line number Diff line change
Expand Up @@ -3333,6 +3333,7 @@ -(void) realPersistState
[values setObject:[NSNumber numberWithBool:self.connectionProperties.supportsModernPubSub] forKey:@"supportsModernPubSub"];
[values setObject:[NSNumber numberWithBool:self.connectionProperties.supportsHTTPUpload] forKey:@"supportsHTTPUpload"];
[values setObject:[NSNumber numberWithBool:self.connectionProperties.supportsPing] forKey:@"supportsPing"];
[values setObject:[NSNumber numberWithBool:self.connectionProperties.supportsExternalServiceDiscovery] forKey:@"supportsExternalServiceDiscovery"];
[values setObject:[NSNumber numberWithBool:self.connectionProperties.supportsRosterPreApproval] forKey:@"supportsRosterPreApproval"];
[values setObject:[NSNumber numberWithBool:self.connectionProperties.supportsBlocking] forKey:@"supportsBlocking"];
[values setObject:[NSNumber numberWithBool:self.connectionProperties.accountDiscoDone] forKey:@"accountDiscoDone"];
Expand Down Expand Up @@ -3531,6 +3532,12 @@ -(void) realReadState
self.connectionProperties.supportsPing = supportsPing.boolValue;
}

if([dic objectForKey:@"supportsExternalServiceDiscovery"])
{
NSNumber* supportsExternalServiceDiscovery = [dic objectForKey:@"supportsExternalServiceDiscovery"];
self.connectionProperties.supportsExternalServiceDiscovery = supportsExternalServiceDiscovery.boolValue;
}

if([dic objectForKey:@"lastInteractionDate"])
_lastInteractionDate = [dic objectForKey:@"lastInteractionDate"];

Expand Down Expand Up @@ -3826,6 +3833,7 @@ -(void) initSession
self.connectionProperties.supportsModernPubSub = NO;
self.connectionProperties.supportsHTTPUpload = NO;
self.connectionProperties.supportsPing = NO;
self.connectionProperties.supportsExternalServiceDiscovery = NO;
self.connectionProperties.supportsRosterPreApproval = NO;

//clear list of running mam queries
Expand Down

0 comments on commit ec9f431

Please sign in to comment.