bsenicar

Wrong parsing of number in phone plugin

Discussion created by bsenicar on Apr 14, 2007

Spark can''t properly parse incoming CallerID if number is not 10 digits long. In that case it will be good to present CLID as received and not to discard it completely.

 

To get proper CLID method setCallerNumber(String number) in src/java/org/jivesoftware/sparkimpl/plugin/phone it should look like this:

 

public void setCallerNumber(String number) {

 

    final StringBuffer buf = new StringBuffer();

    if (number == null) {

        return;

    }

 

    if (number.trim().length() == 10) {

        buf.append("(");

        String areaCode = number.substring(0, 3);

        buf.append(areaCode);

        buf.append(") ");

        String nextThree = number.substring(3, 6);

        buf.append(" ");

        buf.append(nextThree);

        buf.append("-");

        String lastThree = number.substring(6, 10);

        buf.append(lastThree);

    } else {

       buf.append(number);

   }

 

   callerNumberLabel.setText(buf.toString());

}

 

BR

Borut

Outcomes