1. statuses of new subscribtions
2. moving contacts
3. no metter how  you register or add contacts with or without @yahoo.com
cusax-fix
Damian Minkov 19 years ago
parent 929aa6838c
commit 0c193925e1

@ -132,6 +132,13 @@ public class OperationSetPersistentPresenceYahooImpl
* buddy list.
*/
private ServerStoredContactListYahooImpl ssContactList = null;
/**
* Status events are received before subscription one.
* And when subscription is received we deliver
* and the status events.
*/
private StatusUpdater statusUpdater = new StatusUpdater();
public OperationSetPersistentPresenceYahooImpl(
ProtocolProviderServiceYahooImpl provider)
@ -609,6 +616,10 @@ public void subscribe(ContactGroup parent, String contactIdentifier) throws
throw new IllegalArgumentException(
"Argument is not an yahoo contact group (group=" + parent + ")");
if(contactIdentifier.indexOf("@") > -1 )
contactIdentifier =
contactIdentifier.substring(0, contactIdentifier.indexOf("@"));
ssContactList.addContact((ContactGroupYahooImpl)parent, contactIdentifier);
}
@ -846,6 +857,8 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
ssContactList.setYahooSession(yahooProvider.getYahooSession());
initContactStatuses();
addSubsciptionListener(statusUpdater);
}
else if(evt.getNewState() == RegistrationState.UNREGISTERED
|| evt.getNewState() == RegistrationState.AUTHENTICATION_FAILED
@ -860,6 +873,8 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
fireProviderPresenceStatusChangeEvent(oldStatus,
currentStatus);
removeSubscriptionListener(statusUpdater);
//send event notifications saying that all our buddies are
//offline. The protocol does not implement top level buddies
@ -1062,5 +1077,29 @@ public void friendsUpdateReceived(SessionFriendEvent evt)
handleContactStatusChange(sourceContact, evt.getFriend().getStatus());
}
}
}
/**
* Updates the statuses of newly created persistent contacts
*/
private class StatusUpdater implements SubscriptionListener
{
public void subscriptionCreated(SubscriptionEvent evt)
{
ContactYahooImpl contact =
(ContactYahooImpl)evt.getSourceContact();
if(!contact.isPersistent())
return;
handleContactStatusChange(contact,
contact.getSourceContact().getStatus());
}
public void subscriptionFailed(SubscriptionEvent evt) {}
public void subscriptionRemoved(SubscriptionEvent evt) {}
public void subscriptionMoved(SubscriptionMovedEvent evt) {}
public void subscriptionResolved(SubscriptionEvent evt) {}
public void contactModified(ContactPropertyChangeEvent evt) {}
}
}

@ -423,8 +423,8 @@ public void addContact(final ContactGroupYahooImpl parent, final String id)
*/
ContactYahooImpl createVolatileContact(String id)
{
VolatileContactYahooImpl newVolatileContact
= new VolatileContactYahooImpl(id, this);
ContactYahooImpl newVolatileContact
= new ContactYahooImpl(id, this, false);
//Check whether a volatile group already exists and if not create
//one
@ -628,12 +628,14 @@ public void moveContact(ContactYahooImpl contact,
{
try
{
String userID = contact.getAddress();
contactListModListenerImpl.
waitForMove(contact.getSourceContact().getId(),
waitForMove(userID,
contact.getParentContactGroup().getGroupName());
yahooSession.addFriend(
contact.getSourceContact().getId(),
userID,
newParent.getGroupName());
}
catch(IOException ex)
@ -814,7 +816,7 @@ private YahooGroup findGroup(String name)
}
return null;
}
/**
* Imulates firing adding contact in group and moving contact to group.
* When moving contact it is first adding to the new group then
@ -867,7 +869,7 @@ public void friendAddedReceived(SessionFriendEvent ev)
}
String contactID = ev.getFriend().getId();
ContactYahooImpl contactToAdd = findContactById(contactID);
if(contactToAdd == null)
{
contactToAdd =
@ -878,14 +880,23 @@ public void friendAddedReceived(SessionFriendEvent ev)
if(!contactToAdd.isPersistent())
{
// we must remove the volatile buddy as we will add
// the persistent one
// the persistent one.
// Volatile buddy is moving from the volatile group
// to the new one
ContactGroupYahooImpl parent =
(ContactGroupYahooImpl)contactToAdd.getParentContactGroup();
parent.removeContact(contactToAdd);
contactToAdd =
new ContactYahooImpl(ev.getFriend(),
ServerStoredContactListYahooImpl.this, true, true);
contactToAdd.setPersistent(true);
contactToAdd.setResolved(ev.getFriend());
group.addContact(contactToAdd);
fireContactMoved(parent, group, contactToAdd);
waitMove.remove(contactID);
return;
}
Object isWaitingForMove = waitMove.get(contactID);
@ -923,6 +934,8 @@ public void friendAddedReceived(SessionFriendEvent ev)
*/
public void friendRemovedReceived(SessionFriendEvent ev)
{
logger.trace("Receive event for removing a friend : " + ev);
String contactID = ev.getFriend().getId();
// first check is this part of move action

@ -1,81 +0,0 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.protocol.yahoo;
import net.java.sip.communicator.util.Logger;
/**
* The Yahoo implementation for Volatile Contact
* @author Damian Minkov
*/
public class VolatileContactYahooImpl
extends ContactYahooImpl
{
/**
* This contact id
*/
private String contactId = null;
/**
* Creates an Volatile YahooContactImpl with the specified id
* @param id String the user id/address
* @param ssclCallback a reference to the ServerStoredContactListImpl
* instance that created us.
*/
VolatileContactYahooImpl(String id,
ServerStoredContactListYahooImpl ssclCallback)
{
super(id, ssclCallback, false);
this.contactId = id;
}
/**
* Returns the Yahoo Userid of this contact
* @return the Yahoo Userid of this contact
*/
public String getAddress()
{
return contactId;
}
/**
* Returns a String that could be used by any user interacting modules for
* referring to this contact. An alias is not necessarily unique but is
* often more human readable than an address (or id).
* @return a String that can be used for referring to this contact when
* interacting with the user.
*/
public String getDisplayName()
{
return contactId;
}
/**
* Returns a string representation of this contact, containing most of its
* representative details.
*
* @return a string representation of this contact.
*/
public String toString()
{
StringBuffer buff = new StringBuffer("VolatileYahooContact[ id=");
buff.append(getAddress()).append("]");
return buff.toString();
}
/**
* Determines whether or not this contact group is being stored by the
* server. Non persistent contact groups exist for the sole purpose of
* containing non persistent contacts.
* @return true if the contact group is persistent and false otherwise.
*/
public boolean isPersistent()
{
return false;
}
}

@ -25,6 +25,9 @@ public class YahooAccountID
*/
YahooAccountID(String id, Map accountProperties )
{
super(id, accountProperties, ProtocolNames.YAHOO, "yahoo.com");
super((id.indexOf("@") > -1 )
? id.substring(0, id.indexOf("@"))
: id,
accountProperties, ProtocolNames.YAHOO, "yahoo.com");
}
}

@ -42,7 +42,7 @@ public class FirstWizardPage extends JPanel
private JPanel emptyPanel = new JPanel();
private JLabel uinExampleLabel = new JLabel("Ex: johnsmith@hotmail.com");
private JLabel uinExampleLabel = new JLabel("Ex: johnsmith@yahoo.com or johnsmith");
private JTextField uinField = new JTextField();

Loading…
Cancel
Save