Skip to content

Commit

Permalink
Add support for various muc management methods to muc processor
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Dec 29, 2023
1 parent a6809c1 commit f427cfe
Show file tree
Hide file tree
Showing 7 changed files with 318 additions and 15 deletions.
2 changes: 1 addition & 1 deletion 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
8 changes: 6 additions & 2 deletions Monal/Classes/MLMucProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ NS_ASSUME_NONNULL_BEGIN
-(void) join:(NSString*) room;
-(void) leave:(NSString*) room withBookmarksUpdate:(BOOL) updateBookmarks;

-(void) setAffiliation:(NSString*) affiliation ofUser:(NSString*) jid inRoom:(NSString*) roomJid;
-(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;
Expand Down
289 changes: 277 additions & 12 deletions Monal/Classes/MLMucProcessor.m

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Monal/Classes/XMPPIQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import "XMPPStanza.h"
#import "MLContact.h"

@class XMPPDataForm;

NS_ASSUME_NONNULL_BEGIN

FOUNDATION_EXPORT NSString* const kiqGetType;
Expand Down Expand Up @@ -117,6 +119,7 @@ removes a contact from the roster
-(void) setInstantRoom;

-(void) setVcardAvatarWithData:(NSData*) imageData andType:(NSString*) imageType;
-(void) setRemoveVcardAvatar;
-(void) setVcardQuery;

#pragma mark - account
Expand All @@ -130,6 +133,8 @@ removes a contact from the roster
-(void) requestBlockList;

-(void) setMucAdminQueryWithAffiliation:(NSString*) affiliation forJid:(NSString*) jid;
-(void) setGetRoomConfig;
-(void) setRoomConfig:(XMPPDataForm*) configForm;

@end

Expand Down
20 changes: 20 additions & 0 deletions Monal/Classes/XMPPIQ.m
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,33 @@ -(void) getEntitySoftWareVersionTo:(NSString*) to

#pragma mark MUC

-(void) setGetRoomConfig
{
[self addChildNode:[[MLXMLNode alloc] initWithElement:@"query" andNamespace:@"http://jabber.org/protocol/muc#owner"]];
}

-(void) setRoomConfig:(XMPPDataForm*) configForm
{
[self addChildNode:[[MLXMLNode alloc] initWithElement:@"query" andNamespace:@"http://jabber.org/protocol/muc#owner" withAttributes:@{} andChildren:@[configForm] andData:nil]];
}

-(void) setInstantRoom
{
[self addChildNode:[[MLXMLNode alloc] initWithElement:@"query" andNamespace:@"http://jabber.org/protocol/muc#owner" withAttributes:@{} andChildren:@[
[[XMPPDataForm alloc] initWithType:@"submit" andFormType:@"http://jabber.org/protocol/muc#roomconfig"]
] andData:nil]];
}

-(void) setRemoveVcardAvatar
{
[self addChildNode:[[MLXMLNode alloc] initWithElement:@"vCard" andNamespace:@"vcard-temp" withAttributes:@{} andChildren:@[
[[MLXMLNode alloc] initWithElement:@"PHOTO" withAttributes:@{} andChildren:@[
[[MLXMLNode alloc] initWithElement:@"PHOTO" andData:nil],
[[MLXMLNode alloc] initWithElement:@"BINVAL" andData:nil],
] andData:nil]
] andData:nil]];
}

-(void) setVcardAvatarWithData:(NSData*) imageData andType:(NSString*) imageType
{
[self addChildNode:[[MLXMLNode alloc] initWithElement:@"vCard" andNamespace:@"vcard-temp" withAttributes:@{} andChildren:@[
Expand Down
3 changes: 3 additions & 0 deletions Monal/Classes/XMPPPresence.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ allow subscription. Called in response to a remote request.
-(void) unsubscribedContact:(MLContact*) contact;

#pragma mark MUC

-(void) createRoom:(NSString*) room withNick:(NSString*) nick;

/**
join specified room on server
*/
Expand Down
6 changes: 6 additions & 0 deletions Monal/Classes/XMPPPresence.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ -(void) setLastInteraction:(NSDate*) date

#pragma mark MUC

-(void) createRoom:(NSString*) room withNick:(NSString*) nick
{
self.to = [NSString stringWithFormat:@"%@/%@", room, nick];
[self addChildNode:[[MLXMLNode alloc] initWithElement:@"x" andNamespace:@"http://jabber.org/protocol/muc" withAttributes:@{} andChildren:@[] andData:nil]];
}

-(void) joinRoom:(NSString*) room withNick:(NSString*) nick
{
[self.attributes setObject:[NSString stringWithFormat:@"%@/%@", room, nick] forKey:@"to"];
Expand Down

0 comments on commit f427cfe

Please sign in to comment.