if (c == null) { c = getCall(callId, pendingCalls); } int index = getIndex(c.id, gui.calls); if (index == -1) { index = getIndex(c.id, pendingCalls); }
    public boolean changeCallStatus(int callId, String callStatus) {        try {            if (callStatus.equalsIgnoreCase("ACCEPTED")) {                Call c = getCall(callId, gui.calls);                if (c == null) {                    // accepted by user: add call to the list                    c = getCall(callId, pendingCalls);                    //int index = getIndex(c.id, pendingCalls);                    removeCall(callId, pendingCalls);                    gui.calls.addElement(c);                    ImageIcon img = new ImageIcon(cl                            .getResource("gui/resources/green.gif"));                    if (c.name.trim().equalsIgnoreCase("")) {                        img.setDescription(c.sipurl);                    } else {                        img.setDescription(c.sipurl + " (" + c.name + ")");                    }                    gui.list2.addElement(img);                } else {                    // accepted by other side: update call status                    int index = getIndex(c.id, gui.calls);                    gui.list2.removeElementAt(index);                    ImageIcon img = new ImageIcon(cl                            .getResource("gui/resources/green.gif"));                    if (c.name.trim().equalsIgnoreCase("")) {                        img.setDescription(c.sipurl);                    } else {                        img.setDescription(c.sipurl + " (" + c.name + ")");                    }                    gui.list2.insertElementAt(img, index);                }                print("Call # " + callId + " accepted.");            } else if (callStatus.equalsIgnoreCase("TERMINATED")) {                if (getCall(callId, pendingCalls) == null) {                    // hang-up-termination by the other side                    Call c = getCall(callId, gui.calls);                    int index = getIndex(c.id, gui.calls);                    gui.list2.remove(index);                } else { // decline-termination by user                    removeCall(callId, pendingCalls);                }                print("Call # " + callId + " terminated.");            } else {                Call c = getCall(callId, gui.calls);                if (c == null) {                    c = getCall(callId, pendingCalls);                }                int index = getIndex(c.id, gui.calls);                if (index == -1) {                    index = getIndex(c.id, pendingCalls);                }                if (callStatus.equalsIgnoreCase("TRYING")) {                    gui.list2.removeElementAt(index);                    ImageIcon img = new ImageIcon(cl                            .getResource("gui/resources/gray.gif"));                    if (c.name.trim().equalsIgnoreCase("")) {                        img.setDescription(c.sipurl);                    } else {                        img.setDescription(c.sipurl + " (" + c.name + ")");                    }                    gui.list2.insertElementAt(img, index);                } else if (callStatus.equalsIgnoreCase("RINGING")) {                    gui.list2.removeElementAt(index);                    ImageIcon img = new ImageIcon(cl                            .getResource("gui/resources/yellow.gif"));                    if (c.name.trim().equalsIgnoreCase("")) {                        img.setDescription(c.sipurl);                    } else {                        img.setDescription(c.sipurl + " (" + c.name + ")");                    }                    gui.list2.insertElementAt(img, index);                } else if (callStatus.equalsIgnoreCase("DECLINED")) {                    removeCall(callId, gui.calls);                    print("Call # " + callId + " declined.");                } else if (callStatus.equalsIgnoreCase("CANCELLED")) {                    removeCall(callId, gui.calls);                    gui.list2.remove(index);                    print("Call # " + callId + " cancelled.");                } else if (callStatus.equalsIgnoreCase("UNREACHABLE")) {                    removeCall(callId, gui.calls);                    print("Call # " + callId + " unreachable.");                }            }            return true;        } catch (Exception e) {            {                e.printStackTrace();                return false;            }        }    }