Made distinction between finding contacts and creating them when called

from a chat room to initiate a private chat session.
fix-message-formatting
Danny van Heumen 11 years ago
parent 5c0a6aafdf
commit 9b8fb46f9f

@ -28,7 +28,7 @@ public class ChatRoomIrcImpl
/**
* The object used for logging.
*/
private static final Logger logger
private static final Logger LOGGER
= Logger.getLogger(ChatRoomIrcImpl.class);
/**
@ -982,8 +982,8 @@ public void fireMemberPresenceEvent(ChatRoomMember member,
evt = new ChatRoomMemberPresenceChangeEvent(
this, member, eventID, eventReason);
if (logger.isTraceEnabled())
logger.trace("Will dispatch the following ChatRoom event: " + evt);
if (LOGGER.isTraceEnabled())
LOGGER.trace("Will dispatch the following ChatRoom event: " + evt);
Iterable<ChatRoomMemberPresenceListener> listeners;
synchronized (memberListeners)
@ -1016,8 +1016,8 @@ public void fireMemberRoleEvent( ChatRoomMember member,
previousRole,
newRole);
if (logger.isTraceEnabled())
logger.trace("Will dispatch the following ChatRoom event: " + evt);
if (LOGGER.isTraceEnabled())
LOGGER.trace("Will dispatch the following ChatRoom event: " + evt);
Iterable<ChatRoomMemberRoleListener> listeners;
synchronized (memberRoleListeners)
@ -1253,8 +1253,9 @@ public ConferenceDescription publishConference(ConferenceDescription cd,
@Override
public Contact getPrivateContactByNickname(String name)
{
LOGGER.debug("Getting private contact for nick name '" + name + "'.");
return this.parentProvider.getPersistentPresence()
.findContactByID(name);
.findOrCreateContactByID(name);
}
/**

@ -119,6 +119,8 @@ public ProtocolProviderService getProtocolProvider()
@Override
public boolean isPersistent()
{
// TODO implement notion of persistence based on whether or not the nick
// name is registered on the IRC network, for NickServ.
return false;
}
@ -130,6 +132,10 @@ public boolean isPersistent()
@Override
public boolean isResolved()
{
// TODO implement resolved status based on whether or not the nick name
// is registered and the nick is currently "active" according to the
// server, i.e. NickServ.
// For now, we consider the contact unresolved ...
return false;
}
@ -141,6 +147,8 @@ public boolean isResolved()
@Override
public String getPersistentData()
{
// TODO this could retrieve some whois/contact data from NickServ, since
// the "persistent contact" is registered.
return null;
}

@ -835,10 +835,10 @@ private void prepareChatRoom(final ChatRoomIrcImpl chatRoom,
for (IRCUser user : channel.getUsers())
{
ChatRoomMemberRole role = ChatRoomMemberRole.SILENT_MEMBER;
ChatRoomMemberIrcImpl member =
new ChatRoomMemberIrcImpl(this.provider, chatRoom,
user.getNick(), role);
user.getNick(), ChatRoomMemberRole.SILENT_MEMBER);
ChatRoomMemberRole role;
for (IRCUserStatus status : channel.getStatusesForUser(user))
{
role = convertMemberMode(status.getChanModeType().charValue());

@ -162,6 +162,9 @@ public void moveContactToGroup(Contact contactToMove, ContactGroup newParent)
@Override
public ContactGroup getServerStoredContactListRoot()
{
// TODO consider using this for contacts that are registered at NickServ
// for the IRC network. Store contacts and possibly some whois info if
// useful for these contacts as persistent data.
return this.rootGroup;
}
@ -223,8 +226,7 @@ public PresenceStatus queryContactStatus(String contactIdentifier)
@Override
public Contact findContactByID(String contactID)
{
// FIXME DEBUG
LOGGER.warn("findContactByID(\"" + contactID + "\") called");
LOGGER.trace("Finding contact for nick name '" + contactID + "'");
if (contactID == null)
return null;
Contact contact = this.rootGroup.getContact(contactID);
@ -238,8 +240,8 @@ public Contact findContactByID(String contactID)
if (contact != null)
return contact;
}
// FIXME currently just creates a new volatile contact
return createVolatileContact(contactID);
LOGGER.trace("No contact found for nick name '" + contactID + "'");
return null;
}
@Override
@ -261,4 +263,16 @@ public Contact createUnresolvedContact(String address, String persistentData)
{
return null;
}
Contact findOrCreateContactByID(String name)
{
Contact contact = findContactByID(name);
if (contact == null)
{
contact = createVolatileContact(name);
LOGGER.debug("No existing contact found. Created volatile contact"
+ " for nick name '" + name + "'.");
}
return contact;
}
}

Loading…
Cancel
Save