ObjXMPP  Check-in [18872c9f4d]

Overview
Comment:Add methods to generate error and result replies for IQ stanzas
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 18872c9f4dbe62e243fe752482ddbf0fd22fa09bac250ba7ecbd16f70f27117e
User & Date: florob@babelmonkeys.de on 2011-05-12 21:04:49
Other Links: manifest | tags
Context
2011-05-22
21:50
Add dealloc for XMPPJID check-in: 4854b771a9 user: florob@babelmonkeys.de tags: trunk
2011-05-12
21:04
Add methods to generate error and result replies for IQ stanzas check-in: 18872c9f4d user: florob@babelmonkeys.de tags: trunk
20:51
Move namespaces to namespaces.h and add missing files to Xcode project. check-in: 12e4f83535 user: js tags: trunk
Changes

Modified src/XMPPConnection.m from [db4105c296] to [f2b85b75c9].

570
571
572
573
574
575
576
577
578
579
580

581
582
583
584
585
586
587
588
589

590
591
592
593
594
595
596
597
598
599
600
570
571
572
573
574
575
576




577









578




579
580
581
582
583
584
585







-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-








	if ([delegate respondsToSelector: @selector(connection:didReceiveIQ:)])
		handled = [delegate connection: self
				  didReceiveIQ: iq];

	if (!handled && ![[iq type] isEqual: @"error"]
		     && ![[iq type] isEqual: @"result"]) {
		XMPPJID *from = [iq from];
		XMPPJID *to = [iq to];
		OFXMLElement *error;

		[self sendStanza: [iq errorIQWithType: @"cancel"
		[iq setType: @"error"];
		[iq setTo: from];
		[iq setFrom: to];

		error = [OFXMLElement elementWithName: @"error"];
		[error addAttributeWithName: @"type"
				stringValue: @"cancel"];
		[error addChild:
		    [OFXMLElement elementWithName: @"service-unavailable"
					    condition: @"service-unavailable"]];
					namespace: XMPP_NS_STANZAS]];
		[iq addChild: error];

		[self sendStanza: iq];
	}
}

- (void)XMPP_handleMessage: (XMPPMessage*)message
{
	if ([delegate respondsToSelector:
	     @selector(connection:didReceiveMessage:)])

Modified src/XMPPIQ.h from [abd17613f7] to [f689491164].

42
43
44
45
46
47
48





























49
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

 *
 * \param type The value for the stanza's type attribute
 * \param ID The value for the stanza's id attribute
 * \return A initialized XMPPIQ
 */
- initWithType: (OFString*)type
	    ID: (OFString*)ID;

/**
 * Generates a result IQ for the receiving object
 *
 * \return A new autoreleased XMPPIQ
 */
- (XMPPIQ*)resultIQ;

/**
 * Generates a error IQ for the receiving object
 *
 * \param type A error type as defined by RFC 6120
 * \param condition A error condition as defined by RFC 6120
 * \param text A descriptive text
 * \return A new autoreleased XMPPIQ
 */
- (XMPPIQ*)errorIQWithType: (OFString*)type
		 condition: (OFString*)condition
		      text: (OFString*)text;

/**
 * Generates a error IQ for the receiving object
 *
 * \param type A error type as defined by RFC 6120
 * \param condition A defined conditions from RFC 6120
 * \return A new autoreleased XMPPIQ
 */
- (XMPPIQ*)errorIQWithType: (OFString*)type
		 condition: (OFString*)condition;
@end

Modified src/XMPPIQ.m from [3dc875c131] to [e65b289e7d].

17
18
19
20
21
22
23

24
25
26
27
28
29
30
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31







+







 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "namespaces.h"
#import "XMPPIQ.h"

@implementation XMPPIQ
+ IQWithType: (OFString*)type_
	  ID: (OFString*)ID_
{
	return [[[self alloc] initWithType: type_
46
47
48
49
50
51
52












































53
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (XMPPIQ*)resultIQ
{
	XMPPIQ *ret = [XMPPIQ IQWithType: @"result"
				      ID: [self ID]];
	[ret setTo: [self from]];
	[ret setFrom: nil];
	return ret;
}

- (XMPPIQ*)errorIQWithType: (OFString*)type_
		 condition: (OFString*)condition
		      text: (OFString*)text
{
	XMPPIQ *ret = [XMPPIQ IQWithType: @"error"
				      ID: [self ID]];
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *error = [OFXMLElement elementWithName: @"error"
						  namespace: XMPP_NS_CLIENT];

	[error addAttributeWithName: @"type"
			stringValue: type_];
	[error addChild: [OFXMLElement elementWithName: condition
					     namespace: XMPP_NS_STANZAS]];
	if (text)
		[error addChild: [OFXMLElement elementWithName: @"text"
						     namespace: XMPP_NS_STANZAS
						   stringValue: text]];
	[ret addChild: error];
	[ret setTo: [self from]];
	[ret setFrom: nil];

	[pool release];

	return ret;
}

- (XMPPIQ*)errorIQWithType: (OFString*)type_
		 condition: (OFString*)condition
{
	return [self errorIQWithType: type_
			   condition: condition
				text: nil];
}
@end

Modified src/XMPPRoster.m from [c2659e2d1c] to [9da3261919].

158
159
160
161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
158
159
160
161
162
163
164




165
166
167
168
169
170
171
172







-
-
-
-
+







		if (isPush && [[connection delegate] respondsToSelector:
		    @selector(connection:didReceiveRosterItem:)])
			[[connection delegate] connection: connection
				     didReceiveRosterItem: rosterItem];
	}

	if (isPush) {
		XMPPIQ *response = [XMPPIQ IQWithType: @"result"
						   ID: [iq ID]];
		[response setTo: [iq from]];
		[connection sendStanza: response];
		[connection sendStanza: [iq resultIQ]];
	} else {
		if ([[connection delegate] respondsToSelector:
		     @selector(connectionDidReceiveRoster:)])
			[[connection delegate]
			    connectionDidReceiveRoster: connection];

		[rosterID release];