Skip to content

Commit

Permalink
[XEP-0153] Remove redundant request for XMPPStream info.
Browse files Browse the repository at this point in the history
Move self vCard check/request setup from didConnect: to didAuthenticate:.

Add check for empty photo stanza.
  • Loading branch information
echamberlain committed Mar 19, 2011
1 parent e4c71dc commit b25ea34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions Extensions/XEP-0153/XMPPvCardAvatarModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
@property(nonatomic,retain,readonly) XMPPvCardTempModule *xmppvCardTempModule;


- (id)initWithStream:(XMPPStream *)xmppStream
xmppvCardTempModule:(XMPPvCardTempModule *)xmppvCardTempModule;
- (id)initWithvCardTempModule:(XMPPvCardTempModule *)xmppvCardTempModule;


@end
Expand Down
11 changes: 5 additions & 6 deletions Extensions/XEP-0153/XMPPvCardAvatarModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ @implementation XMPPvCardAvatarModule
#pragma mark Init/dealloc methods


- (id)initWithStream:(XMPPStream *)aXmppStream
xmppvCardTempModule:(XMPPvCardTempModule *)xmppvCardTempModule {
if ((self = [super initWithStream:aXmppStream])) {
- (id)initWithvCardTempModule:(XMPPvCardTempModule *)xmppvCardTempModule {
if ((self = [super initWithStream:xmppvCardTempModule.xmppStream])) {
_xmppvCardTempModule = [xmppvCardTempModule retain];
_moduleStorage = (id <XMPPvCardAvatarStorage>)xmppvCardTempModule.moduleStorage;

Expand Down Expand Up @@ -82,7 +81,7 @@ - (void)xmppStreamWillConnect:(XMPPStream *)sender {
}


- (void)xmppStreamDidConnect:(XMPPStream *)sender {
- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender {
[_xmppvCardTempModule fetchvCardTempForJID:[sender myJID] xmppStream:sender useCache:NO];
}

Expand Down Expand Up @@ -114,7 +113,7 @@ - (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)prese

NSString *photoHash = [[xElement elementForName:kXMPPvCardAvatarPhotoElement] stringValue];

if (photoHash == nil) {
if (photoHash == nil || [photoHash isEqualToString:@""]) {
return;
}

Expand All @@ -140,7 +139,7 @@ - (void)xmppvCardTempModule:(XMPPvCardTempModule *)vCardTempModule
* If the client subsequently obtains an avatar image (e.g., by updating or retrieving the vCard),
* it SHOULD then publish a new <presence/> stanza with character data in the <photo/> element.
*/
if ([jid isEqual:[aXmppStream myJID]]) {
if ([jid isEqual:[[aXmppStream myJID] bareJID]]) {
NSXMLElement *presence = [NSXMLElement elementWithName:@"presence"];

[aXmppStream sendElement:presence];
Expand Down

0 comments on commit b25ea34

Please sign in to comment.