Skip to content

Commit 07aa62e

Browse files
authored
Add support for MatrixRTC m.call.notify events. (#1887)
1 parent 96a491b commit 07aa62e

File tree

8 files changed

+229
-0
lines changed

8 files changed

+229
-0
lines changed

MatrixSDK.xcodeproj/project.pbxproj

+32
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,14 @@
647647
8EC5110D256822B400EC4E5B /* MXTaggedEvents.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EC51109256822B400EC4E5B /* MXTaggedEvents.m */; };
648648
918D30B7273951F400A16405 /* MXStoreService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 918D30B6273951F400A16405 /* MXStoreService.swift */; };
649649
918D30B8273951F400A16405 /* MXStoreService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 918D30B6273951F400A16405 /* MXStoreService.swift */; };
650+
918E431C2CDB8C0700F70790 /* MXCallNotify.h in Headers */ = {isa = PBXBuildFile; fileRef = 918E431A2CDB8C0700F70790 /* MXCallNotify.h */; };
651+
918E431D2CDB8C0700F70790 /* MXCallNotify.m in Sources */ = {isa = PBXBuildFile; fileRef = 918E431B2CDB8C0700F70790 /* MXCallNotify.m */; };
652+
918E431E2CDB8C0700F70790 /* MXCallNotify.m in Sources */ = {isa = PBXBuildFile; fileRef = 918E431B2CDB8C0700F70790 /* MXCallNotify.m */; };
653+
918E431F2CDB8C0700F70790 /* MXCallNotify.h in Headers */ = {isa = PBXBuildFile; fileRef = 918E431A2CDB8C0700F70790 /* MXCallNotify.h */; };
654+
918E43222CDB8D6000F70790 /* MXMentions.m in Sources */ = {isa = PBXBuildFile; fileRef = 918E43212CDB8D6000F70790 /* MXMentions.m */; };
655+
918E43232CDB8D6000F70790 /* MXMentions.h in Headers */ = {isa = PBXBuildFile; fileRef = 918E43202CDB8D6000F70790 /* MXMentions.h */; };
656+
918E43242CDB8D6000F70790 /* MXMentions.h in Headers */ = {isa = PBXBuildFile; fileRef = 918E43202CDB8D6000F70790 /* MXMentions.h */; };
657+
918E43252CDB8D6000F70790 /* MXMentions.m in Sources */ = {isa = PBXBuildFile; fileRef = 918E43212CDB8D6000F70790 /* MXMentions.m */; };
650658
91CC0FCA26A033AE00C2A387 /* MXURLPreview.h in Headers */ = {isa = PBXBuildFile; fileRef = 91CC0FC826A033AE00C2A387 /* MXURLPreview.h */; settings = {ATTRIBUTES = (Public, ); }; };
651659
91CC0FCB26A033AE00C2A387 /* MXURLPreview.h in Headers */ = {isa = PBXBuildFile; fileRef = 91CC0FC826A033AE00C2A387 /* MXURLPreview.h */; settings = {ATTRIBUTES = (Public, ); }; };
652660
91CC0FCC26A033AE00C2A387 /* MXURLPreview.m in Sources */ = {isa = PBXBuildFile; fileRef = 91CC0FC926A033AE00C2A387 /* MXURLPreview.m */; };
@@ -2477,6 +2485,10 @@
24772485
8EC51108256822B400EC4E5B /* MXTaggedEvents.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXTaggedEvents.h; sourceTree = "<group>"; };
24782486
8EC51109256822B400EC4E5B /* MXTaggedEvents.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXTaggedEvents.m; sourceTree = "<group>"; };
24792487
918D30B6273951F400A16405 /* MXStoreService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXStoreService.swift; sourceTree = "<group>"; };
2488+
918E431A2CDB8C0700F70790 /* MXCallNotify.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXCallNotify.h; sourceTree = "<group>"; };
2489+
918E431B2CDB8C0700F70790 /* MXCallNotify.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXCallNotify.m; sourceTree = "<group>"; };
2490+
918E43202CDB8D6000F70790 /* MXMentions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXMentions.h; sourceTree = "<group>"; };
2491+
918E43212CDB8D6000F70790 /* MXMentions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXMentions.m; sourceTree = "<group>"; };
24802492
91CC0FC826A033AE00C2A387 /* MXURLPreview.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXURLPreview.h; sourceTree = "<group>"; };
24812493
91CC0FC926A033AE00C2A387 /* MXURLPreview.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXURLPreview.m; sourceTree = "<group>"; };
24822494
91F0685C2767C9FF0079F8FA /* MXTaskProfileName.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXTaskProfileName.h; sourceTree = "<group>"; };
@@ -3660,6 +3672,8 @@
36603672
EC5C562727A36EDB0014CBE9 /* MXInReplyTo.m */,
36613673
327E9ABA2284521C00A98BC1 /* MXEventUnsignedData.h */,
36623674
327E9ABB2284521C00A98BC1 /* MXEventUnsignedData.m */,
3675+
918E43202CDB8D6000F70790 /* MXMentions.h */,
3676+
918E43212CDB8D6000F70790 /* MXMentions.m */,
36633677
);
36643678
path = Event;
36653679
sourceTree = "<group>";
@@ -4366,6 +4380,15 @@
43664380
path = Pods;
43674381
sourceTree = "<group>";
43684382
};
4383+
918E43192CDB8BD900F70790 /* MatrixRTC */ = {
4384+
isa = PBXGroup;
4385+
children = (
4386+
918E431A2CDB8C0700F70790 /* MXCallNotify.h */,
4387+
918E431B2CDB8C0700F70790 /* MXCallNotify.m */,
4388+
);
4389+
path = MatrixRTC;
4390+
sourceTree = "<group>";
4391+
};
43694392
91CC0FC426A0330900C2A387 /* Media */ = {
43704393
isa = PBXGroup;
43714394
children = (
@@ -4946,6 +4969,7 @@
49464969
EC8A536E25B1BC77004E0802 /* MXTurnServerResponse.h */,
49474970
EC8A538A25B1BC77004E0802 /* MXTurnServerResponse.m */,
49484971
EC8A537125B1BC77004E0802 /* Events */,
4972+
918E43192CDB8BD900F70790 /* MatrixRTC */,
49494973
);
49504974
path = Call;
49514975
sourceTree = "<group>";
@@ -5699,6 +5723,7 @@
56995723
EC6D007928E1F15400152144 /* MXDevice.h in Headers */,
57005724
EC619D9324DD834B00663A80 /* MXPushGatewayRestClient.h in Headers */,
57015725
EDE70DC528DA1B7F00099736 /* MXCryptoTools.h in Headers */,
5726+
918E431F2CDB8C0700F70790 /* MXCallNotify.h in Headers */,
57025727
EC60EDE8265CFF3100B39A4E /* MXRoomInviteState.h in Headers */,
57035728
324DD2A6246AE81300377005 /* MXSecretStorageKeyContent.h in Headers */,
57045729
EC60ED8F265CFD3B00B39A4E /* MXRoomSync.h in Headers */,
@@ -5773,6 +5798,7 @@
57735798
323F879625554FF2009E9E67 /* MXTaskProfile_Private.h in Headers */,
57745799
32618E7B20EFA45B00E1D2EA /* MXRoomMembers.h in Headers */,
57755800
B146D4D521A5A44E00D8C2C6 /* MXScanRealmProvider.h in Headers */,
5801+
918E43232CDB8D6000F70790 /* MXMentions.h in Headers */,
57765802
EC60EDD0265CFECC00B39A4E /* MXRoomSyncSummary.h in Headers */,
57775803
EC60EDBC265CFE8600B39A4E /* MXRoomSyncAccountData.h in Headers */,
57785804
32CEEF4323AD2A6C0039BA98 /* MXCrossSigningKey.h in Headers */,
@@ -5893,6 +5919,7 @@
58935919
files = (
58945920
B14EF2D62397E90400758AF0 /* MXMegolmSessionData.h in Headers */,
58955921
EC8A53BA25B1BC77004E0802 /* MXCallEventContent.h in Headers */,
5922+
918E43242CDB8D6000F70790 /* MXMentions.h in Headers */,
58965923
B14EF2BA2397E90400758AF0 /* MXOutgoingRoomKeyRequest.h in Headers */,
58975924
B14EF2FB2397E90400758AF0 /* MXOlmSession.h in Headers */,
58985925
B14EF2DF2397E90400758AF0 /* MXDecryptionResult.h in Headers */,
@@ -6193,6 +6220,7 @@
61936220
B19A30AB2404257700FB6F35 /* MXQRCodeKeyVerificationStart.h in Headers */,
61946221
B14EF34A2397E90400758AF0 /* MXAntivirusScanStatusFormatter.h in Headers */,
61956222
B14EF34B2397E90400758AF0 /* MXEventListener.h in Headers */,
6223+
918E431C2CDB8C0700F70790 /* MXCallNotify.h in Headers */,
61966224
EC60EDE9265CFF3100B39A4E /* MXRoomInviteState.h in Headers */,
61976225
B14EF34C2397E90400758AF0 /* MXMediaScan.h in Headers */,
61986226
B14EF34D2397E90400758AF0 /* MXRoomOperation.h in Headers */,
@@ -6634,6 +6662,7 @@
66346662
EC1165BA27107E330089FA56 /* MXRoomListDataFetcherDelegate.swift in Sources */,
66356663
3275FD9421A6B46600B9C13D /* MXLoginTerms.m in Sources */,
66366664
EC05478425FF99450047ECD7 /* MXRoomAccountDataUpdater.m in Sources */,
6665+
918E431E2CDB8C0700F70790 /* MXCallNotify.m in Sources */,
66376666
ED4114EB292E498100728459 /* MXBackgroundCryptoV2.swift in Sources */,
66386667
B11BD44D22CB56E80064D8B0 /* MXReplyEventParts.m in Sources */,
66396668
32B94E02228EDEBC00716A26 /* MXReactionRelation.m in Sources */,
@@ -6870,6 +6899,7 @@
68706899
C602B58E1F22A8D700B67D87 /* MXImage.swift in Sources */,
68716900
B105CD9D261E0B70006EB204 /* MXSpaceChildrenSummary.swift in Sources */,
68726901
32A9F8E0244720B10069C65B /* MXThrottler.m in Sources */,
6902+
918E43222CDB8D6000F70790 /* MXMentions.m in Sources */,
68736903
EC8A53E425B1BCC6004E0802 /* MXThirdPartyUsersResponse.m in Sources */,
68746904
ED4114E8292E496C00728459 /* MXBackgroundCrypto.swift in Sources */,
68756905
3295401A216385F100E300FC /* MXServerNoticeContent.m in Sources */,
@@ -7260,6 +7290,7 @@
72607290
ECDA762D27B28F3B000C48CF /* MXEventRelationThread.m in Sources */,
72617291
322AB592260CDBC10017E964 /* MXSyncResponseStoreManager.swift in Sources */,
72627292
324AAC7B2399140D00380A66 /* MXKeyVerificationRequestByDMJSONModel.m in Sources */,
7293+
918E431D2CDB8C0700F70790 /* MXCallNotify.m in Sources */,
72637294
B14EF1FD2397E90400758AF0 /* MXReactionOperation.m in Sources */,
72647295
ED4114EC292E498100728459 /* MXBackgroundCryptoV2.swift in Sources */,
72657296
B14EF1FE2397E90400758AF0 /* MXCryptoConstants.m in Sources */,
@@ -7496,6 +7527,7 @@
74967527
ED36ED8728DD9E2200C86416 /* MXCryptoKeyBackupEngine.swift in Sources */,
74977528
B14EF2632397E90400758AF0 /* MXReactionCountChange.m in Sources */,
74987529
324AAC762399140D00380A66 /* MXKeyVerificationCancel.m in Sources */,
7530+
918E43252CDB8D6000F70790 /* MXMentions.m in Sources */,
74997531
32AF928D240EA3880008A0FD /* MXSecretShareSend.m in Sources */,
75007532
B14EF2642397E90400758AF0 /* MXKey.m in Sources */,
75017533
EC8A53B825B1BC77004E0802 /* MXCallCandidatesEventContent.m in Sources */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// Copyright 2024 The Matrix.org Foundation C.I.C
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
#import <Foundation/Foundation.h>
18+
#import "MXJSONModel.h"
19+
#import "MXMentions.h"
20+
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
/**
24+
`MXCallNotify` represents a push notification for a MatrixRTC call,
25+
describing how the user should be notified about the call.
26+
*/
27+
@interface MXCallNotify : MXJSONModel
28+
29+
/**
30+
The application that is running the MatrixRTC session. `m.call` represents a VoIP call.
31+
*/
32+
@property (nonatomic) NSString *application;
33+
34+
/**
35+
Information about who should be notified in the room.
36+
*/
37+
@property (nonatomic) MXMentions *mentions;
38+
39+
/**
40+
Whether the call should ring or deliver a notification.
41+
*/
42+
@property (nonatomic) NSString *notifyType;
43+
44+
/**
45+
A unique identifier for the call that is running. Present for an application type of `m.call`.
46+
*/
47+
@property (nonatomic, nullable) NSString *callID;
48+
49+
@end
50+
51+
NS_ASSUME_NONNULL_END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// Copyright 2024 The Matrix.org Foundation C.I.C
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
#import "MXCallNotify.h"
18+
#import "MXMentions.h"
19+
20+
@implementation MXCallNotify
21+
22+
+ (id)modelFromJSON:(NSDictionary *)JSONDictionary
23+
{
24+
MXCallNotify *callNotify = [[MXCallNotify alloc] init];
25+
if (callNotify)
26+
{
27+
MXJSONModelSetString(callNotify.application, JSONDictionary[@"application"]);
28+
MXJSONModelSetMXJSONModel(callNotify.mentions, MXMentions, JSONDictionary[@"m.mentions"]);
29+
MXJSONModelSetString(callNotify.notifyType, JSONDictionary[@"notify_type"]);
30+
MXJSONModelSetString(callNotify.callID, JSONDictionary[@"call_id"]);
31+
}
32+
33+
return callNotify;
34+
}
35+
36+
- (NSDictionary *)JSONDictionary
37+
{
38+
NSMutableDictionary *JSONDictionary = [NSMutableDictionary dictionary];
39+
40+
JSONDictionary[@"application"] = _application;
41+
JSONDictionary[@"m.mentions"] = _mentions.JSONDictionary;
42+
JSONDictionary[@"notify_type"] = _notifyType;
43+
JSONDictionary[@"call_id"] = _callID;
44+
45+
return JSONDictionary;
46+
}
47+
48+
@end
49+
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// Copyright 2024 The Matrix.org Foundation C.I.C
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
#import <MatrixSDK/MatrixSDK.h>
18+
19+
NS_ASSUME_NONNULL_BEGIN
20+
21+
/**
22+
Describes whether an event mentions other users or the room
23+
*/
24+
@interface MXMentions : MXJSONModel
25+
26+
/**
27+
The user IDs of room members who should be notified about this event.
28+
*/
29+
@property (nonatomic, nullable) NSArray *userIDs;
30+
31+
/**
32+
Whether or not this event contains an @room mention.
33+
*/
34+
@property (nonatomic) BOOL room;
35+
36+
@end
37+
38+
NS_ASSUME_NONNULL_END
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// Copyright 2024 The Matrix.org Foundation C.I.C
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
#import "MXMentions.h"
18+
19+
@implementation MXMentions
20+
21+
+ (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary
22+
{
23+
MXMentions *intentionalMentions = [[MXMentions alloc] init];
24+
if (intentionalMentions)
25+
{
26+
MXJSONModelSetString(intentionalMentions.userIDs, JSONDictionary[@"user_ids"]);
27+
MXJSONModelSetBoolean(intentionalMentions.room, JSONDictionary[@"room"]);
28+
}
29+
30+
return intentionalMentions;
31+
}
32+
33+
- (NSDictionary *)JSONDictionary
34+
{
35+
NSMutableDictionary *JSONDictionary = [NSMutableDictionary dictionary];
36+
37+
JSONDictionary[@"user_ids"] = _userIDs;
38+
JSONDictionary[@"room"] = @(_room);
39+
40+
return JSONDictionary;
41+
}
42+
43+
@end

MatrixSDK/JSONModels/MXEvent.h

+6
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ typedef NS_ENUM(NSInteger, MXEventType)
104104
MXEventTypeBeaconInfo,
105105
MXEventTypeBeacon,
106106
MXEventTypeRoomRetention,
107+
MXEventTypeCallNotify,
107108

108109
// The event is a custom event. Refer to its `MXEventTypeString` version
109110
MXEventTypeCustom = 1000
@@ -317,6 +318,11 @@ FOUNDATION_EXPORT NSString *const kMXJoinRulesContentKeyRoomId;
317318
FOUNDATION_EXPORT NSString *const kMXEventTimelineMain;
318319
FOUNDATION_EXPORT NSString *const kMXEventUnthreaded;
319320

321+
// MatrixRTC support
322+
323+
FOUNDATION_EXPORT NSString *const kMXEventTypeStringCallNotify;
324+
FOUNDATION_EXPORT NSString *const kMXEventTypeStringCallNotifyUnstable;
325+
320326
/**
321327
The internal event state used to handle the different steps of the event sending.
322328
*/

MatrixSDK/JSONModels/MXEvent.m

+5
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@
212212
NSString *const kMXEventTimelineMain = @"main";
213213
NSString *const kMXEventUnthreaded = @"unthreaded";
214214

215+
// Matrix RTC support
216+
217+
NSString *const kMXEventTypeStringCallNotify = @"m.call.notify";
218+
NSString *const kMXEventTypeStringCallNotifyUnstable = @"org.matrix.msc4075.call.notify";
219+
215220
#pragma mark - MXEvent
216221
@interface MXEvent ()
217222
{

MatrixSDK/Utils/MXTools.m

+5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ + (void)initialize
122122
@(MXEventTypeCallRejectReplacement) : kMXEventTypeStringCallRejectReplacement,
123123
@(MXEventTypeCallAssertedIdentity) : kMXEventTypeStringCallAssertedIdentity,
124124
@(MXEventTypeCallAssertedIdentityUnstable) : kMXEventTypeStringCallAssertedIdentityUnstable,
125+
// MatrixRTC call events
126+
@(MXEventTypeCallNotify) : kMXEventTypeStringCallNotifyUnstable,
125127

126128
@(MXEventTypeKeyVerificationRequest) : kMXEventTypeStringKeyVerificationRequest,
127129
@(MXEventTypeKeyVerificationReady) : kMXEventTypeStringKeyVerificationReady,
@@ -194,6 +196,9 @@ + (void)initialize
194196
kMXEventTypeStringCallRejectReplacement : @(MXEventTypeCallRejectReplacement),
195197
kMXEventTypeStringCallAssertedIdentity : @(MXEventTypeCallAssertedIdentity),
196198
kMXEventTypeStringCallAssertedIdentityUnstable : @(MXEventTypeCallAssertedIdentityUnstable),
199+
// MatrixRTC call events
200+
kMXEventTypeStringCallNotify : @(MXEventTypeCallNotify),
201+
kMXEventTypeStringCallNotifyUnstable : @(MXEventTypeCallNotify),
197202

198203
kMXEventTypeStringKeyVerificationRequest : @(MXEventTypeKeyVerificationRequest),
199204
kMXEventTypeStringKeyVerificationReady : @(MXEventTypeKeyVerificationReady),

0 commit comments

Comments
 (0)