Add parent group to contact.

fix-message-formatting
Danny van Heumen 11 years ago
parent b9ba0d4ad0
commit 03be1eaa90

@ -2,14 +2,37 @@
import net.java.sip.communicator.service.protocol.*;
/**
* IRC contact implementation.
*
* @author danny
*/
public class ContactIrcImpl
extends AbstractContact
{
/**
* Parent provider.
*/
private ProtocolProviderServiceIrcImpl provider;
/**
* Contact id.
*/
private String id;
public ContactIrcImpl(ProtocolProviderServiceIrcImpl provider, String id)
/**
* Contact's parent group.
*/
private ContactGroupIrcImpl parentGroup;
/**
* Constructor.
*
* @param provider Protocol provider service instance.
* @param id Contact id.
*/
public ContactIrcImpl(ProtocolProviderServiceIrcImpl provider, String id,
ContactGroupIrcImpl parentGroup)
{
if (provider == null)
throw new IllegalArgumentException("provider cannot be null");
@ -17,63 +40,115 @@ public ContactIrcImpl(ProtocolProviderServiceIrcImpl provider, String id)
if (id == null)
throw new IllegalArgumentException("id cannot be null");
this.id = id;
if (parentGroup == null)
throw new IllegalArgumentException("parentGroup cannot be null");
this.parentGroup = parentGroup;
}
/**
* Get contact id (a.k.a. address)
*
* @return returns id
*/
@Override
public String getAddress()
{
return this.id;
}
/**
* Get contact display name.
*
* @return returns display name
*/
@Override
public String getDisplayName()
{
return this.id;
}
/**
* Get contact image (avatar)
*
* @return returns image data
*/
@Override
public byte[] getImage()
{
return null;
}
/**
* Get presence status.
*
* @return returns presence status
*/
@Override
public PresenceStatus getPresenceStatus()
{
return IrcStatusEnum.ONLINE;
}
/**
* Get parent contact group.
*
* @return returns parent contact group
*/
@Override
public ContactGroup getParentContactGroup()
{
// TODO Auto-generated method stub
return null;
return this.parentGroup;
}
/**
* Get protocol provider service.
*
* @return returns IRC protocol provider service.
*/
@Override
public ProtocolProviderService getProtocolProvider()
{
return this.provider;
}
/**
* Is persistent contact.
*
* @return Returns true if contact is persistent, or false otherwise.
*/
@Override
public boolean isPersistent()
{
return false;
}
/**
* Is contact resolved.
*
* @return Returns true if contact is resolved, or false otherwise.
*/
@Override
public boolean isResolved()
{
return false;
}
/**
* Get persistent data (if any).
*
* @return returns persistent data if available or null otherwise.
*/
@Override
public String getPersistentData()
{
return null;
}
/**
* Get status message.
*
* @return returns status message
*/
@Override
public String getStatusMessage()
{

@ -43,14 +43,10 @@ protected OperationSetPersistentPresenceIrcImpl(
ContactIrcImpl createVolatileContact(String id)
{
ContactIrcImpl newVolatileContact =
new ContactIrcImpl(this.parentProvider, id);
// Check whether a volatile group already exists and if not create
// one
ContactGroupIrcImpl volatileGroup = getNonPersistentGroup();
// if the parent group is null then add necessary create the group
if (volatileGroup == null)
{
volatileGroup =
@ -63,6 +59,10 @@ ContactIrcImpl createVolatileContact(String id)
this.fireServerStoredGroupEvent(volatileGroup,
ServerStoredGroupEvent.GROUP_CREATED_EVENT);
}
// Create volatile contact
ContactIrcImpl newVolatileContact =
new ContactIrcImpl(this.parentProvider, id, volatileGroup);
volatileGroup.addContact(newVolatileContact);
this.fireSubscriptionEvent(newVolatileContact, volatileGroup,

Loading…
Cancel
Save