//Dialog.show(title, body, cmds)Contents.failGtw);
Datas.roster.remove(_roster.getLittleJid());
}
else
{
Jid rost = (Jid)Datas.roster.get(_roster.getLittleJid());
if (rost != null)
rost.setPresence(Presence.getPresence(_presence));
return;
}
}
else if ((midlet.internal_state == ROSTER) && (_roster.getLittleJid().equals(midlet.currentjid.getLittleJid()))) {
if (_roster.status_message.equals(""))
midlet.currentjid.setPresence(Presence.getPresence(_presence));
else
midlet.currentjid.setPresence(Presence.getPresence(_presence), _roster.status_message);
midlet.getGuiRosterItem();
}
else if (midlet.internal_state == ONLINE) {
Jid rost = (Jid)Datas.roster.get(_roster.getLittleJid());
if (rost != null)
{
if (_roster.status_message.equals(""))
rost.setPresence(Presence.getPresence(_presence));
else
rost.setPresence(Presence.getPresence(_presence), _roster.status_message);
}
//String title = _roster.getLittleJid();
//String body = _roster.getUsername() + " is " + Presence.getPresence(_presence);
midlet.getGuiOnlineMenu();
}
else {
// send an alert
String real_presence = Presence.getPresence(_presence);
//String title = _roster.getLittleJid();
//String body = _roster.getUsername() + " is " + real_presence;
//disattivato alert di cambio presence
//display.setCurrent(new Alert(title, body, Datas.images.displayImage(real_presence), AlertType.INFO));
Jid rost = (Jid)Datas.roster.get(_roster.getLittleJid());
if (rost != null)
{
if (_roster.status_message.equals(""))
rost.setPresence(real_presence);
else
rost.setPresence(real_presence, _roster.status_message);
}
}
}
else if (_presence.equals("unsubscribed")) {
if (Datas.isGateway(_roster.getServername())) {
return;//send an alert?
}
if (Datas.roster.get(_roster.getLittleJid()) == null) {
_roster.setPresence(Presence.getPresence("unsubscribed"));
Datas.registerRoster(_roster);
}
midlet.internal_state = ONLINE;
Dialog.show(_roster.getLittleJid()+" added!", "Subscription not accepted/pending.", null, Dialog.TYPE_INFO,null, 3000);
midlet.getGuiOnlineMenu();
}
else if (_presence.equals("subscribed")) {
if ((midlet.currentjid = (Jid)Datas.roster.get(_roster.getLittleJid())) == null) {
Datas.registerRoster(_roster);
midlet.currentjid = _roster;
}
else {
midlet.currentjid.setPresence("subscribed");
}
midlet.internal_state = ROSTER;
Dialog.show("",_roster.getUsername()+" subscribed!", null, Dialog.TYPE_CONFIRMATION,null, 3000);
//display.setCurrent(new Alert(_roster.getUsername()+" subscribed!", "Changes Saved", null, AlertType.CONFIRMATION), midlet.getGuiRosterItem());
}
else if (_presence.equals("subscribe")) {
//save the state
if (midlet.currentjid != null && !midlet.currentjid.getLittleJid().equals(_roster.getLittleJid()))
infopool.put("currentjid", new Jid(midlet.currentjid.getFullJid(), midlet.currentjid.getPresence()));
infopool.put("internal_state", new Integer(midlet.internal_state));
midlet.internal_state = SUBSCRIPTION;
midlet.currentjid = _roster;
midlet.getGuiChoose("subscription");
}