Skip to content

Commit 94edd18

Browse files
author
Andres Canal
committed
added version support
1 parent fd33a51 commit 94edd18

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

Extensions/XEP-0045/XMPPMUC.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ - (BOOL)discoverRoomsForServiceNamed:(NSString *)serviceName
192192
[xmppStream sendElement:iq];
193193
hasRequestedRooms = YES;
194194
}};
195-
195+
196196
if (dispatch_get_specific(moduleQueueTag))
197197
block();
198198
else

Extensions/XMPPMUCLight/XMPPRoomLight.m

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
@interface XMPPRoomLight() {
1717
NSString *roomname;
1818
NSString *subject;
19+
NSString *version;
1920
}
2021
@end
2122

@@ -82,6 +83,12 @@ - (nonnull NSString *)subject {
8283
}
8384
}
8485

86+
- (nonnull NSString *)version {
87+
@synchronized(subject) {
88+
return [version copy];
89+
}
90+
}
91+
8592
- (void)handleConfigElements:(NSArray<NSXMLElement*> *)configElements{
8693
for (NSXMLElement *element in configElements) {
8794
if([element.name isEqualToString:@"subject"]){
@@ -114,6 +121,17 @@ - (void)setSubject:(NSString *)aSubject{
114121
dispatch_async(moduleQueue, block);
115122
}
116123

124+
- (void)setVersion:(NSString *)aVersion{
125+
dispatch_block_t block = ^{ @autoreleasepool {
126+
version = aVersion;
127+
}};
128+
129+
if (dispatch_get_specific(moduleQueueTag))
130+
block();
131+
else
132+
dispatch_async(moduleQueue, block);
133+
}
134+
117135
- (void)createRoomLightWithMembersJID:(nullable NSArray<XMPPJID *> *) members{
118136

119137
// <iq from='[email protected]/desktop'
@@ -295,6 +313,7 @@ - (void)fetchMembersList{
295313
NSString *iqID = [XMPPStream generateUUID];
296314
XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:_roomJID elementID:iqID];
297315
NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:XMPPRoomLightAffiliations];
316+
[query addChild:[NSXMLElement elementWithName:@"version" stringValue:self.version]];
298317
[iq addChild:query];
299318

300319
[responseTracker addID:iqID
@@ -455,7 +474,7 @@ - (void)getConfiguration {
455474
NSString *iqID = [XMPPStream generateUUID];
456475
XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:_roomJID elementID:iqID];
457476
NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:XMPPRoomLightConfiguration];
458-
477+
[query addChild:[NSXMLElement elementWithName:@"version" stringValue:self.version]];
459478
[iq addChild:query];
460479

461480
[responseTracker addID:iqID
@@ -527,12 +546,17 @@ - (void)handleSetConfiguration:(XMPPIQ *)iq withInfo:(id <XMPPTrackingInfo>)info
527546

528547
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq{
529548
NSString *type = [iq type];
530-
531-
if ([type isEqualToString:@"result"] || [type isEqualToString:@"error"])
532-
{
549+
550+
NSXMLElement *query = [iq elementForName:@"query"];
551+
NSXMLElement *version = [query elementForName:@"version"];
552+
if(version){
553+
[self setVersion:version.stringValue];
554+
}
555+
556+
if ([type isEqualToString:@"result"] || [type isEqualToString:@"error"]){
533557
return [responseTracker invokeForID:[iq elementID] withObject:iq];
534558
}
535-
559+
536560
return NO;
537561
}
538562

0 commit comments

Comments
 (0)