use of org.eclipse.ecf.core.user.User in project ecf by eclipse.
the class XMPPContainer method handleConnectResponse.
protected ID handleConnectResponse(ID originalTarget, Object serverData) throws Exception {
if (originalTarget != null && !originalTarget.equals(getID())) {
// First reset target resource to whatever the server says it is
resetTargetResource(originalTarget, serverData);
addNewRemoteMember(originalTarget, null);
final ECFConnection conn = getECFConnection();
accountManager.setConnection(conn.getXMPPConnection());
chatRoomManager.setConnection(getConnectNamespace(), originalTarget, conn);
searchManager.setConnection(getConnectNamespace(), originalTarget, conn);
searchManager.setEnabled(!isGoogle(originalTarget));
presenceHelper.setUser(new User(originalTarget));
outgoingFileTransferContainerAdapter.setConnection(conn.getXMPPConnection());
return originalTarget;
} else
throw new ConnectException(Messages.XMPPContainer_EXCEPTION_INVALID_RESPONSE_FROM_SERVER);
}
use of org.eclipse.ecf.core.user.User in project ecf by eclipse.
the class XMPPContainerPresenceHelper method updatePresenceForMatchingEntry.
private AdditionalClientRosterEntry updatePresenceForMatchingEntry(org.eclipse.ecf.presence.roster.RosterEntry entry, XMPPID fromID, IPresence newPresence) {
final IUser user = entry.getUser();
XMPPID oldID = (XMPPID) user.getID();
// the resource, or create a new client
if (oldID.equals(fromID)) {
if (newPresence.getType() == IPresence.Type.UNAVAILABLE) {
return removeEntryFromRoster(oldID, entry, newPresence, user);
} else {
// set the new presence state
entry.setPresence(newPresence);
// and notify with roster update
rosterManager.notifyRosterUpdate(entry);
}
} else if (oldID.getUsernameAtHost().equals(fromID.getUsernameAtHost())) {
if (oldID.getResourceName() == null) {
oldID.setResourceName(fromID.getResourceName());
// set the new presence state
entry.setPresence(newPresence);
// and notify with roster update
rosterManager.notifyRosterUpdate(entry);
} else if (fromID.getResourceName() != null && !newPresence.getType().equals(IPresence.Type.UNAVAILABLE)) {
return new AdditionalClientRosterEntry(entry.getParent(), new User(fromID, user.getName()), newPresence);
}
}
return null;
}
use of org.eclipse.ecf.core.user.User in project ecf by eclipse.
the class XMPPContainerPresenceHelper method createRosterEntry.
protected IRosterEntry createRosterEntry(ID userID, String name, Iterator grps) {
final List groups = new ArrayList();
for (; grps.hasNext(); ) {
final Object o = grps.next();
final String groupName = (o instanceof String) ? (String) o : ((RosterGroup) o).getName();
final IRosterGroup localGrp = new org.eclipse.ecf.presence.roster.RosterGroup(roster, groupName);
groups.add(localGrp);
}
final IUser user = new User(userID, name);
IRosterEntry newEntry = null;
if (groups.size() == 0)
return new org.eclipse.ecf.presence.roster.RosterEntry(roster, user, new org.eclipse.ecf.presence.Presence(IPresence.Type.UNAVAILABLE, IPresence.Type.UNAVAILABLE.toString(), IPresence.Mode.AWAY));
else
for (int i = 0; i < groups.size(); i++) {
final IRosterGroup grp = (IRosterGroup) groups.get(i);
if (i == 0)
newEntry = new org.eclipse.ecf.presence.roster.RosterEntry(grp, user, null);
else {
grp.getEntries().add(newEntry);
newEntry.getGroups().add(grp);
}
}
return newEntry;
}
Aggregations