use of pl.mn.communicator.GGException in project Openfire by igniterealtime.
the class GaduGaduListener method contactListReceived.
@SuppressWarnings("unchecked")
public void contactListReceived(Collection collection) {
Log.debug("GaduGadu: Contact list received: " + collection);
for (Object localUserObj : collection) {
LocalUser localUser = (LocalUser) localUserObj;
if (localUser.getUin() > 0) {
String ggContact = Integer.toString(localUser.getUin());
String nickname = localUser.getDisplayName();
List<String> groups = new ArrayList<String>();
groups.add(localUser.getGroup());
if (getSession().getPseudoRoster().hasItem(ggContact)) {
PseudoRosterItem rosterItem = getSession().getPseudoRoster().getItem(ggContact);
rosterItem.setNickname(nickname);
rosterItem.setGroups(groups);
} else {
PseudoRosterItem rosterItem = getSession().getPseudoRoster().createItem(ggContact, nickname, groups);
getSession().getBuddyManager().storeBuddy(new GaduGaduBuddy(getSession().getBuddyManager(), localUser, rosterItem));
}
try {
getSession().iSession.getPresenceService().addMonitoredUser(new User(localUser.getUin()));
} catch (GGException e) {
Log.debug("GaduGadu: Error while setting up user to be monitored:", e);
}
} else {
Log.debug("GaduGadu: Ignoring user with UIN less than -1: " + localUser);
}
}
}
use of pl.mn.communicator.GGException in project Openfire by igniterealtime.
the class GaduGaduSession method removeContact.
/**
* @see net.sf.kraken.session.TransportSession#removeContact(net.sf.kraken.roster.TransportBuddy)
*/
@Override
public void removeContact(GaduGaduBuddy contact) {
String ggContact = getTransport().convertJIDToID(contact.getJID());
pseudoRoster.removeItem(ggContact);
for (GaduGaduBuddy buddy : getBuddyManager().getBuddies()) {
if (buddy.getJID().equals(contact.getJID())) {
LocalUser byeUser = buddy.toLocalUser();
try {
iSession.getPresenceService().removeMonitoredUser(new User(byeUser.getUin()));
} catch (GGException e) {
Log.debug("GaduGadu: Error while removing user from being monitored during delete:", e);
}
break;
}
}
}
use of pl.mn.communicator.GGException in project Openfire by igniterealtime.
the class GaduGaduSession method logIn.
/**
* @see net.sf.kraken.session.TransportSession#logIn(net.sf.kraken.type.PresenceType, String)
*/
@Override
public void logIn(PresenceType presenceType, String verboseStatus) {
setPendingPresenceAndStatus(presenceType, verboseStatus);
if (!isLoggedIn()) {
loginContext = new LoginContext(idNumber, registration.getPassword());
listener = new GaduGaduListener(this);
iSession = new Session(new GGConfiguration());
iSession.getConnectionService().addConnectionListener(listener);
iSession.getLoginService().addLoginListener(listener);
iSession.getMessageService().addMessageListener(listener);
iSession.getContactListService().addContactListListener(listener);
iSession.getPresenceService().addUserListener(listener);
try {
IServer iServer = iSession.getConnectionService().lookupServer(idNumber);
iSession.getConnectionService().connect(iServer);
} catch (GGException e) {
Log.debug("GaduGadu: Unable to establish connection:", e);
setFailureStatus(ConnectionFailureReason.CAN_NOT_CONNECT);
sessionDisconnected("Unable to establish connection.");
}
}
}
use of pl.mn.communicator.GGException in project Openfire by igniterealtime.
the class GaduGaduSession method loadRoster.
/**
* Loads the stored roster and adds them to have their presence monitored.
*/
void loadRoster() {
for (String contact : pseudoRoster.getContacts()) {
User user = new User(Integer.valueOf(contact));
// Load actual buddy roster
getBuddyManager().storeBuddy(new GaduGaduBuddy(getBuddyManager(), pseudoRoster.getItem(contact)));
// Set up each roster item to be monitored for presence
try {
iSession.getPresenceService().addMonitoredUser(user);
} catch (GGException e) {
Log.debug("GaduGadu: Error while setting up user to be monitored during add:", e);
}
}
}
use of pl.mn.communicator.GGException in project Openfire by igniterealtime.
the class GaduGaduSession method addContact.
/**
* @see net.sf.kraken.session.TransportSession#addContact(org.xmpp.packet.JID, String, java.util.ArrayList)
*/
@Override
public void addContact(JID jid, String nickname, ArrayList<String> groups) {
String contact = getTransport().convertJIDToID(jid);
if (nickname == null || nickname.length() < 1) {
nickname = jid.toBareJID();
}
LocalUser newUser = new LocalUser();
newUser.setUin(Integer.parseInt(contact));
newUser.setDisplayName(nickname);
if (groups.size() > 0) {
newUser.setGroup(groups.get(0));
}
PseudoRosterItem rosterItem;
if (pseudoRoster.hasItem(contact)) {
rosterItem = pseudoRoster.getItem(contact);
rosterItem.setNickname(nickname);
rosterItem.setGroups(groups);
} else {
rosterItem = pseudoRoster.createItem(contact, nickname, groups);
}
getBuddyManager().storeBuddy(new GaduGaduBuddy(getBuddyManager(), newUser, rosterItem));
try {
iSession.getPresenceService().addMonitoredUser(new User(newUser.getUin()));
} catch (GGException e) {
Log.debug("GaduGadu: Error while setting up user to be monitored during add:", e);
}
}
Aggregations