Permalink
Browse files

More muc work

  • Loading branch information...
1 parent 1c9cafa commit e786130671e27b9d0903063ab20af3c7dbc798ac @robbiehanson committed Dec 2, 2011
Showing with 57 additions and 2 deletions.
  1. +1 −0 Extensions/XEP-0045/XMPPMUC.h
  2. +55 −1 Extensions/XEP-0045/XMPPMUC.m
  3. +1 −1 Extensions/XEP-0054/XMPPvCardTempModule.m
@@ -1,5 +1,6 @@
#import <Foundation/Foundation.h>
#import "XMPP.h"
+#import "XMPPRoom.h"
#define _XMPP_MUC_H
@@ -1,5 +1,5 @@
#import "XMPPMUC.h"
-#import "XMPPRoom.h"
+#import "XMPPFramework.h"
@implementation XMPPMUC
@@ -13,6 +13,33 @@ - (id)initWithDispatchQueue:(dispatch_queue_t)queue
return self;
}
+- (BOOL)activate:(XMPPStream *)aXmppStream
+{
+ if ([super activate:aXmppStream])
+ {
+#ifdef _XMPP_CAPABILITIES_H
+ [xmppStream autoAddDelegate:self delegateQueue:moduleQueue toModulesOfClass:[XMPPCapabilities class]];
+#endif
+
+ return YES;
+ }
+
+ return NO;
+}
+
+- (void)deactivate
+{
+#ifdef _XMPP_CAPABILITIES_H
+ [xmppStream removeAutoDelegate:self delegateQueue:moduleQueue fromModulesOfClass:[XMPPCapabilities class]];
+#endif
+
+ [super deactivate];
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark Public API
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
- (BOOL)isMUCRoomElement:(XMPPElement *)element
{
XMPPJID *bareFrom = [[element from] bareJID];
@@ -71,4 +98,31 @@ - (void)xmppStream:(XMPPStream *)sender willUnregisterModule:(id)module
}
}
+#ifdef _XMPP_CAPABILITIES_H
+/**
+ * If an XMPPCapabilites instance is used we want to advertise our support for MUC.
+**/
+- (void)xmppCapabilities:(XMPPCapabilities *)sender collectingMyCapabilities:(NSXMLElement *)query
+{
+ // This method is invoked on the moduleQueue.
+
+ // <query xmlns="http://jabber.org/protocol/disco#info">
+ // ...
+ // <identity category='client' type='pc'/>
+ // <feature var='http://jabber.org/protocol/muc'/>
+ // ...
+ // </query>
+
+ NSXMLElement *identity = [NSXMLElement elementWithName:@"identity"];
+ [identity addAttributeWithName:@"category" stringValue:@"client"];
+ [identity addAttributeWithName:@"type" stringValue:@"facebook"];
+
+ NSXMLElement *feature = [NSXMLElement elementWithName:@"feature"];
+ [feature addAttributeWithName:@"var" stringValue:@"http://jabber.org/protocol/muc"];
+
+ [query addChild:identity];
+ [query addChild:feature];
+}
+#endif
+
@end
@@ -63,7 +63,7 @@ - (id)initWithvCardStorage:(id <XMPPvCardTempModuleStorage>)storage dispatchQueu
if ((self = [super initWithDispatchQueue:queue]))
{
- if ([storage configureWithParent:self queue:moduleQueue])
+ if ([storage configureWithParent:self queue:moduleQueue])
{
_moduleStorage = storage;
}

0 comments on commit e786130

Please sign in to comment.