MCPcopy Index your code
hub / github.com/BombusMod/BombusMod / updateContact

Method updateContact

src/main/java/Client/Roster.java:520–593  ·  view source on GitHub ↗
(String nick, String jid, String grpName, String subscr, boolean ask)

Source from the content-addressed store, hash-verified

518 }
519
520 public void updateContact(String nick, String jid, String grpName, String subscr, boolean ask) {
521 // called only on roster read
522 int status = Presence.PRESENCE_OFFLINE;
523 if (subscr.equals("none")) {
524 status = Presence.PRESENCE_UNKNOWN;
525 }
526 if (ask) {
527 status = Presence.PRESENCE_ASK;
528 }
529 if (subscr.equals("remove")) {
530 status = -1;
531 }
532
533 Jid J = new Jid(jid);
534 Contact c = findContact(J, false); // search by bare jid
535 if (c == null) {
536 c = new Contact(nick, jid, Presence.PRESENCE_OFFLINE, null);
537 addContact(c);
538//#ifdef JUICK
539 addJuickContact(c);
540//#endif
541 }
542
543 boolean firstInstance = true; //FS#712 workaround
544 int index = 0;
545 synchronized (hContacts) {
546 int j = hContacts.size();
547 for (int i = 0; i < j; i++) {
548 c = (Contact) hContacts.elementAt(i);
549 if (c.jid.equals(J, false)) {
550 Group group = (JidUtils.isTransport(c.jid))
551 ? groups.getGroup(Groups.TYPE_TRANSP)
552 : groups.getGroup(grpName);
553 if (group == null) {
554 group = groups.addGroup(grpName, Groups.TYPE_COMMON);
555 }
556
557 if (status < 0) {
558 hContacts.removeElementAt(index);
559 j--;
560//#ifdef JUICK
561 deleteJuickContact(c);
562//#endif
563 continue;
564 }
565 c.nick = nick;
566 c.group = group;
567 c.subscr = subscr;
568 c.offline_type = status;
569 c.ask_subscribe = ask;
570
571 if (c.origin == Contact.ORIGIN_PRESENCE) {
572 if (firstInstance) {
573 c.origin = Contact.ORIGIN_ROSTERRES;
574 } else {
575 c.origin = Contact.ORIGIN_CLONE;
576 }
577 }

Callers 2

resetRosterMethod · 0.95
processRosterMethod · 0.80

Calls 11

findContactMethod · 0.95
addContactMethod · 0.95
addJuickContactMethod · 0.95
isTransportMethod · 0.95
deleteJuickContactMethod · 0.95
setSortKeyMethod · 0.95
removeTrashMethod · 0.95
addGroupMethod · 0.80
equalsMethod · 0.45
sizeMethod · 0.45
getGroupMethod · 0.45

Tested by

no test coverage detected