adium 5469:cf307a894dbf: The discovery browser now correctly han...
commits at adium.im
commits at adium.im
Tue May 7 14:25:25 UTC 2013
details: http://hg.adium.im/adium/rev/cf307a894dbf
revision: 5469:cf307a894dbf
branch: adium-1.6
author: Thijs Alkemade <me at thijsalkema.de>
date: Tue May 07 16:25:06 2013 +0200
The discovery browser now correctly handles error replies, and doesn't pretend to be waiting forever.
diffs (98 lines):
diff -r 3032c0dd0682 -r cf307a894dbf Plugins/Purple Service/AMPurpleJabberNode.h
--- a/Plugins/Purple Service/AMPurpleJabberNode.h Tue May 07 15:51:06 2013 +0200
+++ b/Plugins/Purple Service/AMPurpleJabberNode.h Tue May 07 16:25:06 2013 +0200
@@ -31,6 +31,9 @@
NSString *node;
NSString *name;
+ NSString *infoIqId;
+ NSString *discoIqId;
+
NSArray *items;
NSSet *features;
NSArray *identities;
@@ -48,6 +51,8 @@
@property (readonly, copy, nonatomic) NSString *name;
@property (readonly, copy, nonatomic) NSString *jid;
@property (readonly, copy, nonatomic) NSString *node;
+ at property (copy, nonatomic) NSString *infoIqId;
+ at property (copy, nonatomic) NSString *discoIqId;
@property (readonly, nonatomic) NSArray *items;
@property (readonly, retain, nonatomic) NSSet *features;
@property (readonly, retain, nonatomic) NSArray *identities;
diff -r 3032c0dd0682 -r cf307a894dbf Plugins/Purple Service/AMPurpleJabberNode.m
--- a/Plugins/Purple Service/AMPurpleJabberNode.m Tue May 07 15:51:06 2013 +0200
+++ b/Plugins/Purple Service/AMPurpleJabberNode.m Tue May 07 16:25:06 2013 +0200
@@ -199,6 +199,29 @@
}
}
+ if (strcmp(type, "error") == 0) {
+ const char *iqId = xmlnode_get_attrib(*packet, "id");
+
+ if ([[NSString stringWithUTF8String:iqId] isEqualToString:self.discoIqId]) {
+
+ self.itemsArray = @[];
+
+ for (id delegate in self.delegates) {
+ if ([delegate respondsToSelector:@selector(jabberNodeGotItems:)])
+ [delegate jabberNodeGotItems:self];
+ }
+ } else if ([[NSString stringWithUTF8String:iqId] isEqualToString:self.infoIqId]) {
+
+ self.identities = @[];
+ self.features = [NSSet set];
+
+ for (id delegate in self.delegates) {
+ if ([delegate respondsToSelector:@selector(jabberNodeGotInfo:)])
+ [delegate jabberNodeGotInfo:self];
+ }
+ }
+ }
+
[pool release];
}
@@ -259,6 +282,8 @@
[name release];
[commands release];
[delegates release];
+ [discoIqId release];
+ [infoIqId release];
[super dealloc];
}
@@ -269,7 +294,11 @@
[iq addAttribute:[NSXMLNode attributeWithName:@"type" stringValue:@"get"]];
if (jid)
[iq addAttribute:[NSXMLNode attributeWithName:@"to" stringValue:jid]];
- [iq addAttribute:[NSXMLNode attributeWithName:@"id" stringValue:[NSString stringWithFormat:@"%@%lu,",[self className], iqCounter++]]];
+
+ assert(discoIqId == NULL);
+ self.discoIqId = [NSString stringWithFormat:@"%@%lu,",[self className], iqCounter++];
+
+ [iq addAttribute:[NSXMLNode attributeWithName:@"id" stringValue:self.discoIqId]];
NSXMLElement *query = [NSXMLNode elementWithName:@"query"];
[query addNamespace:[NSXMLNode namespaceWithName:@"" stringValue:@"http://jabber.org/protocol/disco#items"]];
@@ -294,7 +323,10 @@
[iq addAttribute:[NSXMLNode attributeWithName:@"type" stringValue:@"get"]];
if (jid)
[iq addAttribute:[NSXMLNode attributeWithName:@"to" stringValue:jid]];
- [iq addAttribute:[NSXMLNode attributeWithName:@"id" stringValue:[NSString stringWithFormat:@"%@%lu",[self className], iqCounter++]]];
+
+ assert(infoIqId == NULL);
+ self.infoIqId = [NSString stringWithFormat:@"%@%lu,",[self className], iqCounter++];
+ [iq addAttribute:[NSXMLNode attributeWithName:@"id" stringValue:self.infoIqId]];
NSXMLElement *query = [NSXMLNode elementWithName:@"query"];
[query addNamespace:[NSXMLNode namespaceWithName:@"" stringValue:@"http://jabber.org/protocol/disco#info"]];
@@ -334,7 +366,7 @@
return [commands items];
}
- at synthesize commandsNode = commands, itemsArray = items, identities, features, node, jid, name, gc, delegates;
+ at synthesize commandsNode = commands, itemsArray = items, identities, features, node, jid, name, gc, delegates, infoIqId, discoIqId;
- (void)addDelegate:(id<AMPurpleJabberNodeDelegate>)delegate {
[delegates addObject:delegate];
More information about the commits
mailing list