Search in sources :

Example 1 with MailUpdate

use of net.kano.joscar.snaccmd.mailcheck.MailUpdate in project Openfire by igniterealtime.

the class EmailConnection method handleSnacPacket.

@Override
protected void handleSnacPacket(SnacPacketEvent e) {
    //        Log.debug("OSCAR email snac packet received: "+e);
    SnacCommand cmd = e.getSnacCommand();
    if (cmd instanceof ServerReadyCmd) {
        ServerReadyCmd src = (ServerReadyCmd) cmd;
        setSnacFamilies(src.getSnacFamilies());
        Collection<SnacFamilyInfo> familyInfos = new ArrayList<SnacFamilyInfo>();
        familyInfos.add(ConnCommand.FAMILY_INFO);
        familyInfos.add(MailCheckCmd.FAMILY_INFO);
        setSnacFamilyInfos(familyInfos);
        getMainSession().registerSnacFamilies(this);
        request(new ClientVersionsCmd(familyInfos));
        request(new RateInfoRequest());
    } else if (cmd instanceof MailUpdate) {
        MailUpdate mu = (MailUpdate) cmd;
        if (JiveGlobals.getBooleanProperty("plugin.gateway." + getMainSession().getTransport().getType() + ".mailnotifications", true) && lastMailCount < mu.getUnreadCount()) {
            Integer diff = mu.getUnreadCount() - lastMailCount;
            if (diff > 0) {
                getMainSession().getTransport().sendMessage(getMainSession().getJID(), getMainSession().getTransport().getJID(), LocaleUtils.getLocalizedString("gateway.oscar.mail", "kraken", Arrays.asList(Integer.toString(diff), mu.getDomain(), mu.getUrl())), Message.Type.headline);
            }
        }
        lastMailCount = mu.getUnreadCount();
    } else {
        super.handleSnacPacket(e);
    }
}
Also used : SnacFamilyInfo(net.kano.joscar.snaccmd.conn.SnacFamilyInfo) ServerReadyCmd(net.kano.joscar.snaccmd.conn.ServerReadyCmd) MailUpdate(net.kano.joscar.snaccmd.mailcheck.MailUpdate) ClientVersionsCmd(net.kano.joscar.snaccmd.conn.ClientVersionsCmd) ArrayList(java.util.ArrayList) SnacCommand(net.kano.joscar.flapcmd.SnacCommand) RateInfoRequest(net.kano.joscar.snaccmd.conn.RateInfoRequest)

Aggregations

ArrayList (java.util.ArrayList)1 SnacCommand (net.kano.joscar.flapcmd.SnacCommand)1 ClientVersionsCmd (net.kano.joscar.snaccmd.conn.ClientVersionsCmd)1 RateInfoRequest (net.kano.joscar.snaccmd.conn.RateInfoRequest)1 ServerReadyCmd (net.kano.joscar.snaccmd.conn.ServerReadyCmd)1 SnacFamilyInfo (net.kano.joscar.snaccmd.conn.SnacFamilyInfo)1 MailUpdate (net.kano.joscar.snaccmd.mailcheck.MailUpdate)1