-
Notifications
You must be signed in to change notification settings - Fork 2
/
XMPPInfoQueryStanza.m
83 lines (76 loc) · 1.86 KB
/
XMPPInfoQueryStanza.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// XMPPInfoQueryStanza.m
// Jabber
//
// Created by David Chisnall on 30/05/2006.
// Copyright 2006 __MyCompanyName__. All rights reserved.
//
#import "XMPPInfoQueryStanza.h"
#import "XMPPInfoQueryStanzaFactory.h"
#import "XMPPIdentity.h"
#import <EtoileFoundation/EtoileFoundation.h>
static NSDictionary * TYPES;
@implementation XMPPInfoQueryStanza
+ (void) initialize
{
TYPES = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:IQ_TYPE_SET], @"set",
[NSNumber numberWithInt:IQ_TYPE_GET], @"get",
[NSNumber numberWithInt:IQ_TYPE_RESULT], @"result",
[NSNumber numberWithInt:IQ_TYPE_ERROR], @"error",
nil];
}
- (id) initWithXMLParser: (ETXMLParser*)aParser
key: (id)aKey
{
self = [super initWithXMLParser: aParser
key: aKey];
if (nil == self)
{
return nil;
}
children = [NSMutableDictionary new];
return self;
}
- (void)startElement:(NSString *)aName
attributes:(NSDictionary*)attributes
{
if([aName isEqualToString:@"iq"])
{
depth++;
type = [[TYPES objectForKey:[attributes objectForKey:@"type"]] intValue];
jid = [[JID alloc] initWithString:[attributes objectForKey:@"from"]];
sequenceID = [attributes objectForKey:@"id"];
}
else
{
XMPPInfoQueryStanzaFactory * factory = [XMPPInfoQueryStanzaFactory sharedStazaFactory];
NSString * xmlns = [attributes objectForKey:@"xmlns"];
if([aName isEqualToString:@"query"])
{
queryxmlns = xmlns;
}
Class handler = [factory handlerForTag:aName inNamespace:xmlns];
NSString * elementKey = [factory valueForTag:aName inNamespace:xmlns];
[[[handler alloc] initWithXMLParser:parser
key:elementKey] startElement:aName
attributes:attributes];
}
}
- (NSString*) sequenceID
{
return sequenceID;
}
- (JID*) jid
{
return jid;
}
- (iq_type_t) type
{
return type;
}
- (NSString*) queryNamespace
{
return queryxmlns;
}
@end