Overview
Comment: | Request and handle roster. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b74a310cc362edadbbc5dff428db56cf |
User & Date: | js on 2011-03-21 19:51:17 |
Other Links: | manifest | tags |
Context
2011-03-21
| ||
20:36 | Send an error reply for unhandled IQ stanzas. check-in: f4868153e6 user: js tags: trunk | |
19:51 | Request and handle roster. check-in: b74a310cc3 user: js tags: trunk | |
18:27 | Generate unique IDs and free all instance variables on dealloc. check-in: 913f68c8af user: js tags: trunk | |
Changes
Modified src/Makefile from [61a2f5a5b5] to [992c84981f].
1 | 1 2 3 4 5 6 | - + | all: |
Modified src/XMPPConnection.h from [48873be5e7] to [eb4dbab3f1].
︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | + | @class XMPPAuthenticator; @protocol XMPPConnectionDelegate @optional - (void)connectionWasAuthenticated: (XMPPConnection*)conn; - (void)connection: (XMPPConnection*)conn wasBoundToJID: (XMPPJID*)jid; - (void)connectionDidReceiveRoster: (XMPPConnection*)conn; - (void)connection: (XMPPConnection*)conn didReceiveIQ: (XMPPIQ*)iq; - (void)connection: (XMPPConnection*)conn didReceivePresence: (XMPPPresence*)pres; - (void)connection: (XMPPConnection*)conn didReceiveMessage: (XMPPMessage*)msg; - (void)connectionWasClosed: (XMPPConnection*)conn; |
︙ | |||
58 59 60 61 62 63 64 | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | - + + + | uint16_t port; /// Whether to use TLS BOOL useTLS; id <XMPPConnectionDelegate, OFObject> delegate; XMPPAuthenticator *authModule; BOOL needsSession; unsigned int lastID; |
︙ | |||
90 91 92 93 94 95 96 97 | 93 94 95 96 97 98 99 100 101 102 103 104 105 | + + + + + | /** * Generates a new, unique stanza ID. * * \return A new, generated, unique stanza ID. */ - (OFString*)generateStanzaID; /** * Requests the roster. */ - (void)requestRoster; @end |
Modified src/XMPPConnection.m from [0ae0e9e2bc] to [374e4b1629].
︙ | |||
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 | 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | + + - + + - - - + + + - - + + - - + + + + + + + + + + | #import "XMPPIQ.h" #import "XMPPMessage.h" #import "XMPPPresence.h" #import "XMPPExceptions.h" #define NS_BIND @"urn:ietf:params:xml:ns:xmpp-bind" #define NS_CLIENT @"jabber:client" #define NS_ROSTER @"jabber:iq:roster" #define NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl" #define NS_STARTTLS @"urn:ietf:params:xml:ns:xmpp-tls" #define NS_SESSION @"urn:ietf:params:xml:ns:xmpp-session" #define NS_STREAM @"http://etherx.jabber.org/streams" @interface XMPPConnection () - (void)XMPP_startStream; - (void)XMPP_sendAuth: (OFString*)name; - (void)XMPP_handleFeatures: (OFXMLElement*)elem; - (void)XMPP_handleIQ: (XMPPIQ*)iq; - (void)XMPP_handleMessage: (XMPPMessage*)msg; - (void)XMPP_handlePresence: (XMPPPresence*)pres; - (void)XMPP_sendResourceBind; - (void)XMPP_handleResourceBind: (XMPPIQ*)iq; - (void)XMPP_sendSession; - (void)XMPP_handleSession: (XMPPIQ*)iq; - (void)XMPP_handleRoster: (XMPPIQ*)iq; @end @implementation XMPPConnection |
︙ | |||
381 382 383 384 385 386 387 | 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | - + - + + + + + + | @"<stream:stream to='%@' xmlns='" NS_CLIENT @"' " @"xmlns:stream='" NS_STREAM @"' " @"version='1.0'>", server]; } - (void)XMPP_handleIQ: (XMPPIQ*)iq { |
︙ | |||
504 505 506 507 508 509 510 | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | - + + + + + + | [iq addChild: bind]; [self sendStanza: iq]; } - (void)XMPP_handleResourceBind: (XMPPIQ*)iq { |
︙ | |||
552 553 554 555 556 557 558 559 | 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 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | if ([delegate respondsToSelector: @selector(connection:wasBoundToJID:)]) [delegate connection: self wasBoundToJID: JID]; [sessionID release]; sessionID = nil; } - (void)requestRoster { XMPPIQ *iq; if (rosterID != nil) assert(0); rosterID = [[self generateStanzaID] retain]; iq = [XMPPIQ IQWithType: @"get" ID: rosterID]; [iq addChild: [OFXMLElement elementWithName: @"query" namespace: NS_ROSTER]]; [self sendStanza: iq]; } - (void)XMPP_handleRoster: (XMPPIQ*)iq { OFXMLElement *rosterElem; if (![iq.type isEqual: @"result"]) assert(0); rosterElem = iq.children.firstObject; if (![rosterElem.name isEqual: @"query"] || ![rosterElem.namespace isEqual: NS_ROSTER]) assert(0); for (OFXMLElement *elem in rosterElem.children) { OFString *group; OFMutableArray *rosterGroup; if (![elem.name isEqual: @"item"] || ![elem.ns isEqual: NS_ROSTER]) continue; group = [[elem elementsForName: @"group" namespace: NS_ROSTER].firstObject stringValue]; if (group == nil) group = @""; if ((rosterGroup = [roster objectForKey: group]) == nil) { rosterGroup = [OFMutableArray array]; [roster setObject: rosterGroup forKey: group]; } [rosterGroup addObject: elem]; } if ([delegate respondsToSelector: @selector(connectionDidReceiveRoster:)]) [delegate connectionDidReceiveRoster: self]; [rosterID release]; rosterID = nil; } @end |
Modified tests/Makefile from [45abb6a72d] to [8334b4231c].
1 | 1 2 3 4 5 | - + | all: |
Modified tests/test.m from [b2456e219f] to [05cdbc9644].
︙ | |||
107 108 109 110 111 112 113 114 115 | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | + + + + + + + - + | { of_log(@"Auth successful"); } - (void)connection: (XMPPConnection*)conn wasBoundToJID: (XMPPJID*)jid { of_log(@"Bound to JID: %@", [jid fullJID]); [conn requestRoster]; } - (void)connectionDidReceiveRoster :(XMPPConnection*)conn { XMPPPresence *pres; |
︙ |