Search in sources :

Example 6 with User

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);
}
Also used : User(org.eclipse.ecf.core.user.User) MUCUser(org.jivesoftware.smackx.packet.MUCUser) ECFConnection(org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection) ConnectException(java.net.ConnectException) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException)

Example 7 with User

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;
}
Also used : User(org.eclipse.ecf.core.user.User) IUser(org.eclipse.ecf.core.user.IUser) IUser(org.eclipse.ecf.core.user.IUser) XMPPID(org.eclipse.ecf.provider.xmpp.identity.XMPPID)

Example 8 with User

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;
}
Also used : User(org.eclipse.ecf.core.user.User) IUser(org.eclipse.ecf.core.user.IUser) ArrayList(java.util.ArrayList) IRosterGroup(org.eclipse.ecf.presence.roster.IRosterGroup) RosterGroup(org.eclipse.ecf.presence.roster.RosterGroup) IRosterGroup(org.eclipse.ecf.presence.roster.IRosterGroup) IUser(org.eclipse.ecf.core.user.IUser) IPresence(org.eclipse.ecf.presence.IPresence) Presence(org.jivesoftware.smack.packet.Presence) List(java.util.List) ArrayList(java.util.ArrayList) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry)

Aggregations

User (org.eclipse.ecf.core.user.User)8 IUser (org.eclipse.ecf.core.user.IUser)6 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)3 ConnectException (java.net.ConnectException)1 URISyntaxException (java.net.URISyntaxException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)1 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)1 ECFConnection (org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection)1 IPresence (org.eclipse.ecf.presence.IPresence)1 IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)1 IRosterGroup (org.eclipse.ecf.presence.roster.IRosterGroup)1 RosterGroup (org.eclipse.ecf.presence.roster.RosterGroup)1 IResultList (org.eclipse.ecf.presence.search.IResultList)1 ResultList (org.eclipse.ecf.presence.search.ResultList)1 Presence (org.jivesoftware.smack.packet.Presence)1 Row (org.jivesoftware.smackx.ReportedData.Row)1