use of net.kano.joscar.snaccmd.loc.SetInfoCmd in project Openfire by igniterealtime.
the class BOSConnection method handleSnacResponse.
@Override
protected void handleSnacResponse(SnacResponseEvent e) {
super.handleSnacResponse(e);
// Log.debug("OSCAR bos snac response received: "+e);
SnacCommand cmd = e.getSnacCommand();
if (cmd instanceof LocRightsCmd) {
request(new SetInfoCmd(new InfoData("oscargateway", null, getMainSession().getCapabilities(), null)));
request(new MyInfoRequest());
} else if (cmd instanceof ParamInfoCmd) {
ParamInfoCmd pic = (ParamInfoCmd) cmd;
ParamInfo info = pic.getParamInfo();
request(new SetParamInfoCmd(new ParamInfo(0, info.getFlags() | ParamInfo.FLAG_TYPING_NOTIFICATION, 8000, info.getMaxSenderWarning(), info.getMaxReceiverWarning(), 0)));
} else if (cmd instanceof ServiceRedirect) {
ServiceRedirect sr = (ServiceRedirect) cmd;
getMainSession().connectToService(sr.getSnacFamily(), sr.getRedirectHost(), sr.getCookie());
} else if (cmd instanceof SsiDataCmd) {
SsiDataCmd sdc = (SsiDataCmd) cmd;
List<SsiItem> items = sdc.getItems();
for (SsiItem item : items) {
SsiItemObj obj = itemFactory.getItemObj(item);
if (obj instanceof BuddyItem) {
BuddyItem bi = (BuddyItem) obj;
Log.debug("OSCAR: got buddy item " + bi);
getMainSession().getSsiHierarchy().gotBuddy(bi);
} else if (obj instanceof GroupItem) {
GroupItem gi = (GroupItem) obj;
Log.debug("OSCAR: got group item " + gi);
getMainSession().getSsiHierarchy().gotGroup(gi);
} else if (obj instanceof IconItem) {
IconItem ii = (IconItem) obj;
Log.debug("OSCAR: got icon item " + ii);
getMainSession().getSsiHierarchy().gotIconItem(ii);
} else if (obj instanceof VisibilityItem) {
VisibilityItem vi = (VisibilityItem) obj;
Log.debug("OSCAR: got visibility item " + vi);
getMainSession().getSsiHierarchy().gotVisibilityItem(vi);
} else {
Log.debug("OSCAR: got item we're not handling " + obj);
}
}
if (sdc.getLastModDate() != 0) {
request(new ActivateSsiCmd());
clientReady();
getMainSession().setLoginStatus(TransportLoginStatus.LOGGED_IN);
getMainSession().gotCompleteSSI();
}
} else if (cmd instanceof OfflineMsgIcqCmd) {
OfflineMsgIcqCmd omic = (OfflineMsgIcqCmd) cmd;
String sn = String.valueOf(omic.getFromUIN());
Date whenSent = omic.getDate();
ByteBlock block = omic.getIcqData();
final int len = LEBinaryTools.getUShort(block, 12) - 1;
String msg = OscarTools.getString(block.subBlock(14, len), null);
msg = StringUtils.unescapeFromXML(OscarTools.stripHtml(msg));
// TODO: Translate offline message note
getMainSession().getTransport().sendOfflineMessage(getMainSession().getJID(), getMainSession().getTransport().convertIDToJID(sn), msg, whenSent, "Offline Message");
} else if (cmd instanceof OfflineMsgDoneCmd) {
request(new OfflineMsgIcqAckCmd(getMainSession().getUIN(), (int) getMainSession().nextIcqId()));
} else if (cmd instanceof MetaShortInfoCmd) {
// MetaShortInfoCmd msic = (MetaShortInfoCmd)cmd;
// Log.debug("RECEIVED META SHORT INFO: "+msic);
// getMainSession().updateRosterNickname(String.valueOf(msic.getUIN()), msic.getNickname());
} else if (cmd instanceof AuthReplyCmd) {
AuthReplyCmd ar = (AuthReplyCmd) cmd;
if (ar.isAccepted()) {
Presence p = new Presence();
p.setType(Presence.Type.subscribed);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(ar.getSender()));
getMainSession().getTransport().sendPacket(p);
} else {
Presence p = new Presence();
p.setType(Presence.Type.unsubscribed);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(ar.getSender()));
getMainSession().getTransport().sendPacket(p);
}
} else if (cmd instanceof AuthFutureCmd) {
AuthFutureCmd af = (AuthFutureCmd) cmd;
Presence p = new Presence();
p.setType(Presence.Type.subscribe);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(af.getUin()));
getMainSession().getTransport().sendPacket(p);
} else if (cmd instanceof SnacError) {
SnacError se = (SnacError) cmd;
if (se.getErrorCode() == SnacError.CODE_REFUSED_BY_CLIENT) {
getMainSession().getTransport().sendMessage(getMainSession().getJID(), getMainSession().getTransport().getJID(), LocaleUtils.getLocalizedString("gateway.aim.msgrefused", "kraken"));
}
//TODO: Tons more errors that can be caught. Gotta catch 'em all! =) (please don't sue me Nintendo)
}
}
use of net.kano.joscar.snaccmd.loc.SetInfoCmd in project Openfire by igniterealtime.
the class OSCARSession method gotCompleteSSI.
/**
* Apparently we now have the entire list, lets sync.
*/
void gotCompleteSSI() {
ArrayList<Integer> nicknameRequests = new ArrayList<Integer>();
TransportBuddyManager<OSCARBuddy> manager = getBuddyManager();
for (OSCARBuddy buddy : manager.getBuddies()) {
String nickname = buddy.getNickname();
buddy.populateGroupList();
for (BuddyItem buddyItem : buddy.getBuddyItems()) {
if (buddyItem.isAwaitingAuth()) {
buddy.setAskType(RosterItem.ASK_SUBSCRIBE);
buddy.setSubType(RosterItem.SUB_NONE);
}
try {
if (nickname.equalsIgnoreCase(buddyItem.getScreenname())) {
Integer buddyUIN = Integer.parseInt(buddyItem.getScreenname());
Log.debug("REQUESTING SHORT INFO FOR " + buddyUIN);
nicknameRequests.add(buddyUIN);
}
} catch (NumberFormatException e) {
// Not an ICQ number then ;D
}
}
}
try {
getTransport().syncLegacyRoster(getJID(), getBuddyManager().getBuddies());
} catch (UserNotFoundException e) {
Log.debug("Unable to sync oscar contact list for " + getJID(), e);
}
getBuddyManager().activate();
request(new SetInfoCmd(InfoData.forCapabilities(getCapabilities())));
// if (JiveGlobals.getBooleanProperty("plugin.gateway."+getTransport().getType()+".avatars", true) && getAvatar() != null) {
// if (storedIconInfo == null || !StringUtils.encodeHex(storedIconInfo.getIconInfo().getData().toByteArray()).equals(getAvatar().getLegacyIdentifier())) {
// try {
// updateLegacyAvatar(getAvatar().getMimeType(), Base64.decode(getAvatar().getImageData()));
// }
// catch (NotFoundException e) {
// // No avatar found, moving on
// }
// }
// }
updateStatus(getPresence(), getVerboseStatus());
ssiHierarchy.setVisibilityFlag(VisibilityItem.MASK_DISABLE_RECENT_BUDDIES);
if (getTransport().getType().equals(TransportType.icq)) {
request(new OfflineMsgIcqRequest(getUIN(), (int) nextIcqId()));
}
if (JiveGlobals.getBooleanProperty("plugin.gateway." + getTransport().getType() + ".mailnotifications", true)) {
request(new ServiceRequest(MailCheckCmd.FAMILY_MAILCHECK));
}
for (Integer uin : nicknameRequests) {
MetaShortInfoRequest req = new MetaShortInfoRequest(getUIN(), (int) nextIcqId(), uin);
Log.debug("Doing a MetaShortInfoRequest for " + uin + " as " + req);
request(req);
}
}
use of net.kano.joscar.snaccmd.loc.SetInfoCmd in project Openfire by igniterealtime.
the class OSCARSession method updateStatus.
/**
* @see net.sf.kraken.session.TransportSession#updateStatus(net.sf.kraken.type.PresenceType, String)
*/
@Override
public void updateStatus(PresenceType presenceType, String verboseStatus) {
if (getTransport().getType().equals(TransportType.icq)) {
request(new SetExtraInfoCmd(((OSCARTransport) getTransport()).convertXMPPStatusToICQ(presenceType)));
}
if (presenceType != PresenceType.available && presenceType != PresenceType.chat) {
String awayMsg = LocaleUtils.getLocalizedString("gateway.oscar.away", "kraken");
if (verboseStatus != null && verboseStatus.length() > 0) {
awayMsg = verboseStatus;
}
request(new SetInfoCmd(InfoData.forAwayMessage(awayMsg)));
if (!getTransport().getType().equals(TransportType.icq)) {
presenceType = PresenceType.away;
}
} else {
request(new SetInfoCmd(InfoData.forAwayMessage(InfoData.NOT_AWAY)));
request(new SetExtraInfoCmd(new ExtraInfoBlock(ExtraInfoBlock.TYPE_AVAILMSG, ExtraInfoData.getAvailableMessageBlock(verboseStatus == null ? "" : verboseStatus))));
}
setPresenceAndStatus(presenceType, verboseStatus);
}
Aggregations