Overview
Context
Changes
Modified src/XMPPConnection.m
from [150ec0f157]
to [15582e8207].
︙ | | |
559
560
561
562
563
564
565
566
567
568
569
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
|
559
560
561
562
563
564
565
566
567
568
569
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
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
|
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
|
- (void)sendIQ: (XMPPIQ*)IQ
callbackTarget: (id)target
selector: (SEL)selector
{
OFAutoreleasePool *pool;
XMPPCallback *callback;
OFString *ID, *key;
pool = [[OFAutoreleasePool alloc] init];
if (![IQ ID])
[IQ setID: [self generateStanzaID]];
pool = [[OFAutoreleasePool alloc] init];
if ((ID = [IQ ID]) == nil) {
ID = [self generateStanzaID];
[IQ setID: ID];
}
if ((key = [[IQ to] fullJID]) == nil)
key = [_JID bareJID];
if (key == nil) // Only happens for resource bind
key = @"bind";
key = [key stringByAppendingString: ID];
callback = [XMPPCallback callbackWithTarget: target
selector: selector];
[_callbacks setObject: callback
forKey: [IQ ID]];
forKey: key];
[pool release];
[self sendStanza: IQ];
}
#ifdef OF_HAVE_BLOCKS
- (void)sendIQ: (XMPPIQ*)IQ
callbackBlock: (xmpp_callback_block_t)block
{
OFAutoreleasePool *pool;
XMPPCallback *callback;
OFString *ID, *key;
pool = [[OFAutoreleasePool alloc] init];
if (![IQ ID])
[IQ setID: [self generateStanzaID]];
pool = [[OFAutoreleasePool alloc] init];
if ((ID = [IQ ID]) == nil) {
ID = [self generateStanzaID];
[IQ setID: ID];
}
if ((key = [[IQ to] fullJID]) == nil)
key = [_JID bareJID];
if (key == nil) // Connection not yet bound, can't send stanzas
@throw [OFInvalidArgumentException exception];
key = [key stringByAppendingString: ID];
callback = [XMPPCallback callbackWithBlock: block];
[_callbacks setObject: callback
forKey: [IQ ID]];
forKey: key];
[pool release];
[self sendStanza: IQ];
}
#endif
- (OFString*)generateStanzaID
|
︙ | | |
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
|
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
|
-
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
|
exceptionWithConnection: self
reason: [element XMLString]];
}
assert(0);
}
- (void)XMPP_handleIQ: (XMPPIQ*)iq
- (void)XMPP_handleIQ: (XMPPIQ*)IQ
{
bool handled = false;
XMPPCallback *callback;
OFString *key;
if ((key = [[IQ from] fullJID]) == nil)
key = [_JID bareJID];
if (key == nil) // Only happens for resource bind
key = @"bind";
key = [key stringByAppendingString: [IQ ID]];
if ((callback = [_callbacks objectForKey: [iq ID]])) {
[callback runWithIQ: iq
if ((callback = [_callbacks objectForKey: key])) {
[callback runWithIQ: IQ
connection: self];
[_callbacks removeObjectForKey: [iq ID]];
[_callbacks removeObjectForKey: key];
return;
}
handled = [_delegates broadcastSelector: @selector(
connection:didReceiveIQ:)
withObject: self
withObject: iq];
withObject: IQ];
if (!handled && ![[iq type] isEqual: @"error"] &&
![[iq type] isEqual: @"result"]) {
[self sendStanza: [iq errorIQWithType: @"cancel"
if (!handled && ![[IQ type] isEqual: @"error"] &&
![[IQ type] isEqual: @"result"]) {
[self sendStanza: [IQ errorIQWithType: @"cancel"
condition: @"service-unavailable"]];
}
}
- (void)XMPP_handleMessage: (XMPPMessage*)message
{
[_delegates broadcastSelector: @selector(connection:didReceiveMessage:)
|
︙ | | |