Skip to content

Commit 9086220

Browse files
6.4.12 (#1440)
- Fixed handling of fromUser and toUser in muc mam queries MACOS_ONLY - Removed keyboard shortcut for "archive conversation" MACOS_ONLY - MacOS Menu entires are now translatable - Contacts from the address book can now be shared again., thanks Melvo - Fix crashes when connectivity is unstable - Don't play call error sounds indefinitely - Fix bug in roster subscription handling
2 parents ea33080 + a37931a commit 9086220

File tree

7 files changed

+64
-32
lines changed

7 files changed

+64
-32
lines changed

Monal/Classes/AVCallUI.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,8 @@ struct AVCallUI: View {
610610
UIApplication.shared.isIdleTimerDisabled = true
611611

612612
self.ringingPlayer.numberOfLoops = -1
613-
self.busyPlayer.numberOfLoops = -1
614-
self.errorPlayer.numberOfLoops = -1
613+
self.busyPlayer.numberOfLoops = 6
614+
self.errorPlayer.numberOfLoops = 6
615615

616616
//ask for mic permissions
617617
AVAudioSession.sharedInstance().requestRecordPermission { granted in

Monal/Classes/HelperTools.m

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,16 +1187,27 @@ +(void) handleUploadItemProvider:(NSItemProvider*) provider withCompletionHandle
11871187
}*/
11881188
else if([provider hasItemConformingToTypeIdentifier:UTTypeContact.identifier])
11891189
{
1190-
[provider loadItemForTypeIdentifier:UTTypeContact.identifier options:nil completionHandler:^(NSURL* _Nullable item, NSError* _Null_unspecified error) {
1191-
if(error != nil || item == nil)
1190+
[provider loadDataRepresentationForTypeIdentifier:UTTypeContact.identifier completionHandler:^(NSData* data, NSError* error) {
1191+
if(error != nil || data == nil)
11921192
{
1193-
DDLogError(@"Error extracting item from NSItemProvider: %@", error);
1194-
payload[@"error"] = error;
1195-
return completion(payload);
1193+
DDLogWarn(@"Got error, retrying with NSURL: %@", error);
1194+
[provider loadItemForTypeIdentifier:UTTypeContact.identifier options:nil completionHandler:^(NSURL* _Nullable item, NSError* _Null_unspecified error) {
1195+
if(error != nil || item == nil)
1196+
{
1197+
DDLogError(@"Error extracting contact item from NSItemProvider: %@", error);
1198+
payload[@"error"] = error;
1199+
return completion(payload);
1200+
}
1201+
DDLogInfo(@"Got contact item NSURL: %@", item);
1202+
payload[@"type"] = @"contact";
1203+
return prepareFile(item);
1204+
}];
1205+
return;
11961206
}
1197-
DDLogInfo(@"Got contact item: %@", item);
1207+
DDLogInfo(@"Got contact item NSData: %@", data);
11981208
payload[@"type"] = @"contact";
1199-
return prepareFile(item);
1209+
payload[@"data"] = [MLFiletransfer prepareDataUpload:data withFileExtension:@"vcf"];
1210+
return [HelperTools addUploadItemPreviewForItem:nil provider:provider andPayload:payload withCompletionHandler:completion];
12001211
}];
12011212
}
12021213
else if([provider hasItemConformingToTypeIdentifier:UTTypeFileURL.identifier])

Monal/Classes/MLUDPLogger.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,18 @@ -(void) realLogMessage:(DDLogMessage*) logMessage isDirect:(BOOL) direct
290290
[[self class] logError:@"not sending message, too big: %lu", (unsigned long)data.length];
291291
else
292292
dispatch_async(_send_queue, ^{
293-
[self sendData:data withOriginalMessage:logMessage->_message];
293+
[self sendData:data withOriginalMessage:logMessage->_message andRetryCounter:0];
294294
});
295295
}
296296

297-
-(void) sendData:(NSData*) data withOriginalMessage:(NSString*) msg
297+
-(void) sendData:(NSData*) data withOriginalMessage:(NSString*) msg andRetryCounter:(int) retryCounter
298298
{
299+
if(retryCounter>8)
300+
{
301+
[[self class] logError:@"not retrying send, retry counter reached: %@", msg];
302+
return;
303+
}
304+
299305
[self createConnectionIfNeeded];
300306

301307
//the call to dispatch_get_main_queue() is a dummy because we are using DISPATCH_DATA_DESTRUCTOR_DEFAULT which is performed inline
@@ -326,7 +332,7 @@ -(void) sendData:(NSData*) data withOriginalMessage:(NSString*) msg
326332
//retry
327333
//[self disconnect];
328334
[[self class] logError:@"retrying sendData with error: %@", _last_error];
329-
[self sendData:data withOriginalMessage:msg];
335+
[self sendData:data withOriginalMessage:msg andRetryCounter:retryCounter+1];
330336
}
331337
}
332338

Monal/Classes/MonalAppDelegate.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,23 +1315,23 @@ -(void) buildMenuWithBuilder:(id<UIMenuBuilder>) builder
13151315
{
13161316
[super buildMenuWithBuilder:builder];
13171317
//monal
1318-
UIKeyCommand* preferencesCommand = [UIKeyCommand commandWithTitle:@"Preferences..." image:nil action:@selector(showSettings) input:@"," modifierFlags:UIKeyModifierCommand propertyList:nil];
1318+
UIKeyCommand* preferencesCommand = [UIKeyCommand commandWithTitle:NSLocalizedString(@"Preferences...", @"") image:nil action:@selector(showSettings) input:@"," modifierFlags:UIKeyModifierCommand propertyList:nil];
13191319

13201320
UIMenu* preferencesMenu = [UIMenu menuWithTitle:@"" image:nil identifier:@"im.monal.preferences" options:UIMenuOptionsDisplayInline children:@[preferencesCommand]];
13211321
[builder insertSiblingMenu:preferencesMenu afterMenuForIdentifier:UIMenuAbout];
13221322

13231323
//file
1324-
UIKeyCommand* newCommand = [UIKeyCommand commandWithTitle:@"New Message" image:nil action:@selector(showNew) input:@"N" modifierFlags:UIKeyModifierCommand propertyList:nil];
1324+
UIKeyCommand* newCommand = [UIKeyCommand commandWithTitle:NSLocalizedString(@"New Message", @"") image:nil action:@selector(showNew) input:@"N" modifierFlags:UIKeyModifierCommand propertyList:nil];
13251325

13261326
UIMenu* newMenu = [UIMenu menuWithTitle:@"" image:nil identifier:@"im.monal.new" options:UIMenuOptionsDisplayInline children:@[newCommand]];
13271327
[builder insertChildMenu:newMenu atStartOfMenuForIdentifier:UIMenuFile];
13281328

1329-
UIKeyCommand* detailsCommand = [UIKeyCommand commandWithTitle:@"Details..." image:nil action:@selector(showDetails) input:@"I" modifierFlags:UIKeyModifierCommand propertyList:nil];
1329+
UIKeyCommand* detailsCommand = [UIKeyCommand commandWithTitle:NSLocalizedString(@"Details...", @"") image:nil action:@selector(showDetails) input:@"I" modifierFlags:UIKeyModifierCommand propertyList:nil];
13301330

13311331
UIMenu* detailsMenu = [UIMenu menuWithTitle:@"" image:nil identifier:@"im.monal.detail" options:UIMenuOptionsDisplayInline children:@[detailsCommand]];
13321332
[builder insertSiblingMenu:detailsMenu afterMenuForIdentifier:@"im.monal.new"];
13331333

1334-
UIKeyCommand* deleteCommand = [UIKeyCommand commandWithTitle:@"Delete Conversation" image:nil action:@selector(deleteConversation) input:@"\b" modifierFlags:UIKeyModifierCommand propertyList:nil];
1334+
UICommand* deleteCommand = [UICommand commandWithTitle:NSLocalizedString(@"Archive Conversation", @"") image:nil action:@selector(deleteConversation) propertyList:nil];
13351335

13361336
UIMenu* deleteMenu = [UIMenu menuWithTitle:@"" image:nil identifier:@"im.monal.delete" options:UIMenuOptionsDisplayInline children:@[deleteCommand]];
13371337
[builder insertSiblingMenu:deleteMenu afterMenuForIdentifier:@"im.monal.detail"];

Monal/Classes/xmpp.m

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,7 @@ -(void) processInput:(MLXMLNode*) parsedStanza withDelayedReplay:(BOOL) delayedR
19181918
// check if we need a contact request
19191919
NSDictionary* contactSub = [[DataLayer sharedInstance] getSubscriptionForContact:contact.contactJid andAccount:contact.accountId];
19201920
DDLogVerbose(@"Got subscription request for contact %@ having subscription status: %@", presenceNode.fromUser, contactSub);
1921-
if(!contactSub || !([[contactSub objectForKey:@"subscription"] isEqualToString:kSubTo] || [[contactSub objectForKey:@"subscription"] isEqualToString:kSubBoth]))
1921+
if(!contactSub || !([[contactSub objectForKey:@"subscription"] isEqualToString:kSubFrom] || [[contactSub objectForKey:@"subscription"] isEqualToString:kSubBoth]))
19221922
[[DataLayer sharedInstance] addContactRequest:contact];
19231923
else if(contactSub && [[contactSub objectForKey:@"subscription"] isEqualToString:kSubTo])
19241924
[self addToRoster:contact withPreauthToken:nil];
@@ -2134,6 +2134,27 @@ -(void) processInput:(MLXMLNode*) parsedStanza withDelayedReplay:(BOOL) delayedR
21342134
//create a new XMPPMessage node instead of only a MLXMLNode because messages have some convenience properties and methods
21352135
messageNode = [[XMPPMessage alloc] initWithXMPPMessage:[outerMessageNode findFirst:@"{urn:xmpp:mam:2}result/{urn:xmpp:forward:0}forwarded/{jabber:client}message"]];
21362136

2137+
//sanity check: if mam query is not our own archive, this is a muc archive and the fromUser or toUser of
2138+
//the inner stanza should always match the bare jid of our muc we queried the archive of
2139+
XMPPIQ* mamQueryNode = _runningMamQueries[[outerMessageNode findFirst:@"{urn:xmpp:mam:2}result@queryid"]]; //we already checked for existence above
2140+
if(
2141+
//not queried our own archive
2142+
!(
2143+
mamQueryNode.toUser==nil ||
2144+
[@"" isEqualToString:mamQueryNode.toUser] ||
2145+
[self.connectionProperties.identity.jid isEqualToString:mamQueryNode.toUser]
2146+
//but fromUser or toUser is not the bare jid we queried the archive from
2147+
) && (
2148+
![messageNode.fromUser isEqualToString:mamQueryNode.toUser] ||
2149+
![messageNode.toUser isEqualToString:mamQueryNode.toUser]
2150+
)
2151+
) {
2152+
DDLogError(@"muc mam results must not contain 1:1 message stanzas, ignoring this spoofed mam result having queryid: %@!", [outerMessageNode findFirst:@"{urn:xmpp:mam:2}result@queryid"]);
2153+
//even these stanzas have to be counted by smacks
2154+
[self incrementLastHandledStanzaWithDelayedReplay:delayedReplay];
2155+
return;
2156+
}
2157+
21372158
//move mam:2 delay timestamp into forwarded message stanza if the forwarded stanza does not have one already
21382159
//that makes parsing a lot easier later on and should not do any harm, even when resending/forwarding this inner stanza
21392160
if([outerMessageNode check:@"{urn:xmpp:mam:2}result/{urn:xmpp:forward:0}forwarded/{urn:xmpp:delay}delay"] && ![messageNode check:@"{urn:xmpp:delay}delay"])
@@ -2463,7 +2484,7 @@ -(void) processInput:(MLXMLNode*) parsedStanza withDelayedReplay:(BOOL) delayedR
24632484
return [self invalidXMLError];
24642485

24652486
//record TLS version
2466-
self.connectionProperties.tlsVersion = [((MLStream*)self->_oStream) isTLS13] ? @"1.3" : @"1.2";
2487+
self.connectionProperties.tlsVersion = [((MLStream*)self->_oStream) streamStatus] == NSStreamStatusOpen ? ([((MLStream*)self->_oStream) isTLS13] ? @"1.3" : @"1.2") : @"unknown";
24672488

24682489
NSString* message = [parsedStanza findFirst:@"text#"];;
24692490
if([parsedStanza check:@"not-authorized"])
@@ -2506,7 +2527,7 @@ -(void) processInput:(MLXMLNode*) parsedStanza withDelayedReplay:(BOOL) delayedR
25062527
return [self invalidXMLError];
25072528

25082529
//record TLS version
2509-
self.connectionProperties.tlsVersion = [((MLStream*)self->_oStream) isTLS13] ? @"1.3" : @"1.2";
2530+
self.connectionProperties.tlsVersion = [((MLStream*)self->_oStream) streamStatus] == NSStreamStatusOpen ? ([((MLStream*)self->_oStream) isTLS13] ? @"1.3" : @"1.2") : @"unknown";
25102531

25112532
//perform logic to handle sasl success
25122533
DDLogInfo(@"Got SASL Success");
@@ -2604,7 +2625,9 @@ -(void) processInput:(MLXMLNode*) parsedStanza withDelayedReplay:(BOOL) delayedR
26042625
return;
26052626
}
26062627

2607-
NSData* channelBindingData = [((MLStream*)self->_oStream) channelBindingDataForType:[self channelBindingToUse]];
2628+
NSData* channelBindingData = nil;
2629+
if([((MLStream*)self->_oStream) streamStatus] == NSStreamStatusOpen)
2630+
channelBindingData = [((MLStream*)self->_oStream) channelBindingDataForType:[self channelBindingToUse]];
26082631
MLXMLNode* responseXML = [[MLXMLNode alloc] initWithElement:@"response" andNamespace:@"urn:xmpp:sasl:2" withAttributes:@{} andChildren:@[] andData:[HelperTools encodeBase64WithString:[self->_scramHandler clientFinalMessageWithChannelBindingData:channelBindingData]]];
26092632
[self send:responseXML];
26102633

@@ -2684,7 +2707,7 @@ -(void) processInput:(MLXMLNode*) parsedStanza withDelayedReplay:(BOOL) delayedR
26842707
self.connectionProperties.supportsSSDP = self->_scramHandler.ssdpSupported;
26852708

26862709
//record TLS version
2687-
self.connectionProperties.tlsVersion = [((MLStream*)self->_oStream) isTLS13] ? @"1.3" : @"1.2";
2710+
self.connectionProperties.tlsVersion = [((MLStream*)self->_oStream) streamStatus] == NSStreamStatusOpen ? ([((MLStream*)self->_oStream) isTLS13] ? @"1.3" : @"1.2") : @"unknown";
26882711

26892712
//make sure this error is reported, even if there are other SRV records left (we disconnect here and won't try again)
26902713
[HelperTools postError:message withNode:nil andAccount:self andIsSevere:YES andDisableAccount:YES];
@@ -2721,7 +2744,7 @@ -(void) processInput:(MLXMLNode*) parsedStanza withDelayedReplay:(BOOL) delayedR
27212744
self.connectionProperties.supportsSSDP = self->_scramHandler.ssdpSupported;
27222745

27232746
//record TLS version
2724-
self.connectionProperties.tlsVersion = [((MLStream*)self->_oStream) isTLS13] ? @"1.3" : @"1.2";
2747+
self.connectionProperties.tlsVersion = [((MLStream*)self->_oStream) streamStatus] == NSStreamStatusOpen ? ([((MLStream*)self->_oStream) isTLS13] ? @"1.3" : @"1.2") : @"unknown";
27252748

27262749
self->_scramHandler = nil;
27272750
self->_blockToCallOnTCPOpen = nil; //just to be sure but not strictly necessary
@@ -4564,14 +4587,6 @@ -(void) removeFromRoster:(MLContact*) contact
45644587
//delete contact request if it exists
45654588
[[DataLayer sharedInstance] deleteContactRequest:contact];
45664589

4567-
XMPPPresence* presence = [XMPPPresence new];
4568-
[presence unsubscribeContact:contact];
4569-
[self send:presence];
4570-
4571-
XMPPPresence* presence2 = [XMPPPresence new];
4572-
[presence2 unsubscribedContact:contact];
4573-
[self send:presence2];
4574-
45754590
XMPPIQ* iq = [[XMPPIQ alloc] initWithType:kiqSetType];
45764591
[iq setRemoveFromRoster:contact];
45774592
[self send:iq];

Monal/localization/external

Submodule external updated 87 files

0 commit comments

Comments
 (0)