Skip to content

Instantly share code, notes, and snippets.

@soulfly
Created November 26, 2012 13:17
Show Gist options
  • Save soulfly/4148141 to your computer and use it in GitHub Desktop.
Save soulfly/4148141 to your computer and use it in GitHub Desktop.
BlackBerry chat sample 5,6,7: Add the new contacts to the contact list
chat_manager.internal_state = chat_manager.ONLINE;
boolean changes = false; // test if there are changes
boolean onlyphone = false;
boolean isNew = true;
if (chat_manager.currentjid == null ||
!jid.getText().equals(chat_manager.currentjid.getFullJid()) ||
!group.getText().equals(chat_manager.currentjid.group) || (phone.getText() != null &&
!phone.getText().equals(chat_manager.currentjid.phone))) {
if (chat_manager.currentjid != null &&
jid.getText().equals(chat_manager.currentjid.getFullJid()) &&
group.getText().equals(chat_manager.currentjid.group)) {
onlyphone = true; //only phone number changes
}
changes = true;
}
if (chat_manager.currentjid != null) {
Datas.roster.remove(chat_manager.currentjid.getLittleJid());
isNew = false;
}
if (onlyphone) {
chat_manager.currentjid.phone = phone.getText();
Subscribe.setPhoneNumber(chat_manager.currentjid,
chat_manager.currentjid.phone);
Datas.roster.put(chat_manager.currentjid.getLittleJid(),
chat_manager.currentjid);
} else if (changes) {
Jid newjid = new Jid(jid.getText());
newjid.group = group.getText();
newjid.phone = phone.getText();
//notify to the server
Subscribe.setNewRosterItem(newjid, isNew);
Datas.registerRoster(newjid);
if (newjid.phone != null && !newjid.phone.equals("")) {
Subscribe.setPhoneNumber(newjid, newjid.phone);
}
}
chat_manager.getGuiOnlineMenu();
onClose();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment