diff --git a/lib/installer-exclude/ymsg_network_v0_63.jar b/lib/installer-exclude/ymsg_network_v0_63.jar index bf1dde1b3..96e2043fe 100644 Binary files a/lib/installer-exclude/ymsg_network_v0_63.jar and b/lib/installer-exclude/ymsg_network_v0_63.jar differ diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ServerStoredContactListYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ServerStoredContactListYahooImpl.java index 9e324e740..9a0acc958 100644 --- a/src/net/java/sip/communicator/impl/protocol/yahoo/ServerStoredContactListYahooImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/yahoo/ServerStoredContactListYahooImpl.java @@ -1046,6 +1046,111 @@ public void pictureReceived(SessionPictureEvent ev) ContactPropertyChangeEvent.PROPERTY_IMAGE, contact, null, ev.getPictureData()); } + + /** + * Process Authorization responses + * @param ev the event to process + */ + public void authorizationReceived(SessionAuthorizationEvent ev) + { + if(ev.isAuthorizationAccepted()) + { + logger.trace("authorizationAccepted from " + ev.getFrom()); + Contact srcContact = findContactById(ev.getFrom()); + + if(srcContact == null) + logger.trace("No contact found"); + else + handler.processAuthorizationResponse( + new AuthorizationResponse( + AuthorizationResponse.ACCEPT, + ev.getMessage()), + srcContact); + } + else if(ev.isAuthorizationDenied()) + { + logger.trace("authorizationDenied from " + ev.getFrom()); + Contact srcContact = findContactById(ev.getFrom()); + + if(srcContact == null) + logger.trace("No contact found"); + else + { + handler.processAuthorizationResponse( + new AuthorizationResponse( + AuthorizationResponse.REJECT, + ev.getMessage()), + srcContact); + try + { + removeContact((ContactYahooImpl)srcContact); + } catch (Exception ex) + { + logger.error("cannot remove denied contact : " + + srcContact, ex); + } + } + } + else if(ev.isAuthorizationRequest()) + { + logger.trace("authorizationRequestReceived from " + ev.getFrom()); + Contact srcContact = findContactById(ev.getFrom()); + + // if there is no such contact we create it as + // volatile so we can fire notification + // and then if accepted add it in the protocol + // so we can receive its states + boolean isCurrentlyCreated = false; + if(srcContact == null) + { + srcContact = createVolatileContact(ev.getFrom()); + isCurrentlyCreated = true; + } + + AuthorizationRequest authRequest = new AuthorizationRequest(); + authRequest.setReason(ev.getMessage()); + + AuthorizationResponse authResponse = + handler.processAuthorisationRequest( + authRequest, srcContact); + + if (authResponse.getResponseCode() == AuthorizationResponse.IGNORE) + return; + else + if (authResponse.getResponseCode() == AuthorizationResponse.REJECT) + { + removeContact((ContactYahooImpl)srcContact); + try + { + yahooSession.rejectFriendAuthorization( + ev, ev.getFrom(), authResponse.getReason()); + }catch(IOException ex) + { + logger.error("cannot send auth deny", ex); + } + } + + // else we accepted it + try + { + yahooSession.acceptFriendAuthorization(ev, ev.getFrom()); + } + catch(IOException ex) + { + logger.error("cannot send auth deny", ex); + } + + if(isCurrentlyCreated) + try + { + addContact(ev.getFrom()); + } + catch (OperationFailedException ex) + { + logger.error("Cannot add friend", ex); + } + } + } } /** diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPresence.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPresence.java index de653cb45..bacaae2ee 100644 --- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPresence.java +++ b/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPresence.java @@ -287,7 +287,7 @@ public void subtestStateTransition( YahooStatusEnum newStatus) PresenceStatusEventCollector statusEventCollector2 = new PresenceStatusEventCollector(); ContactPresenceEventCollector statusEventCollector1 - = new ContactPresenceEventCollector(fixture.userID1, newStatus); + = new ContactPresenceEventCollector(fixture.userID2, newStatus); operationSetPresence2.addProviderPresenceStatusListener( statusEventCollector2); operationSetPresence1.addContactPresenceStatusListener( @@ -456,7 +456,7 @@ public void postTestSubscribe() .removeContactPresenceStatusListener(contactPresEvtCollector); } } - + assertEquals("Presence Notif. event dispatching failed." , 1, contactPresEvtCollector.collectedEvents.size()); ContactPresenceStatusChangeEvent presEvt =