1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2011, 2019, Jonathan Schleifer <js@webkeks.org>
* Copyright (c) 2011, 2019, 2021, Jonathan Schleifer <js@nil.im>
* Copyright (c) 2011, Florian Zeitz <florob@babelmonkeys.de>
*
* https://heap.zone/objxmpp/
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
|
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
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
-
+
-
-
+
-
-
+
-
-
+
-
-
|
#include "config.h"
#import "namespaces.h"
#import "XMPPIQ.h"
@implementation XMPPIQ
+ (instancetype)IQWithType: (OFString *)type
+ (instancetype)IQWithType: (OFString *)type ID: (OFString *)ID
ID: (OFString *)ID
{
return [[[self alloc] initWithType: type
return [[[self alloc] initWithType: type ID: ID] autorelease];
ID: ID] autorelease];
}
- (instancetype)initWithType: (OFString *)type
- (instancetype)initWithType: (OFString *)type ID: (OFString *)ID
ID: (OFString *)ID
{
self = [super initWithName: @"iq"
self = [super initWithName: @"iq" type: type ID: ID];
type: type
ID: ID];
@try {
if (![type isEqual: @"get"] && ![type isEqual: @"set"] &&
![type isEqual: @"result"] && ![type isEqual: @"error"])
@throw [OFInvalidArgumentException exception];
} @catch (id e) {
[self release];
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
-
+
-
+
-
-
+
-
+
-
+
-
-
+
-
-
|
condition: (OFString *)condition
text: (OFString *)text
{
XMPPIQ *ret = [XMPPIQ IQWithType: @"error"
ID: self.ID];
void *pool = objc_autoreleasePoolPush();
OFXMLElement *error = [OFXMLElement elementWithName: @"error"
namespace: XMPP_NS_CLIENT];
namespace: XMPPClientNS];
[error addAttributeWithName: @"type"
[error addAttributeWithName: @"type" stringValue: type];
stringValue: type];
[error addChild: [OFXMLElement elementWithName: condition
namespace: XMPP_NS_STANZAS]];
namespace: XMPPStanzasNS]];
if (text)
[error addChild: [OFXMLElement elementWithName: @"text"
namespace: XMPP_NS_STANZAS
namespace: XMPPStanzasNS
stringValue: text]];
[ret addChild: error];
ret.to = self.from;
ret.from = nil;
objc_autoreleasePoolPop(pool);
return ret;
}
- (XMPPIQ *)errorIQWithType: (OFString *)type
- (XMPPIQ *)errorIQWithType: (OFString *)type condition: (OFString *)condition
condition: (OFString *)condition
{
return [self errorIQWithType: type
return [self errorIQWithType: type condition: condition text: nil];
condition: condition
text: nil];
}
@end
|