private void deleteSMS(String cmd,String search){
  int nbDeleted=-2;
  if (cmd.equals("all")) {
    nbDeleted=mSmsManager.deleteAllSms();
  }
 else   if (cmd.equals("sent")) {
    nbDeleted=mSmsManager.deleteSentSms();
  }
 else   if (cmd.startsWith("last")) {
    Integer number=Tools.parseInt(search);
    if (number == null) {
      number=1;
    }
    if (cmd.equals("last")) {
      nbDeleted=mSmsManager.deleteLastSms(number);
    }
 else     if (cmd.equals("lastin")) {
      nbDeleted=mSmsManager.deleteLastInSms(number);
    }
 else     if (cmd.equals("lastout")) {
      nbDeleted=mSmsManager.deleteLastOutSms(number);
    }
 else {
      send(R.string.chat_del_sms_error);
    }
  }
 else   if (cmd.equals("contact") && search != null) {
    ArrayList<Contact> contacts=ContactsManager.getMatchingContacts(sContext,search);
    if (contacts.size() > 1) {
      StringBuilder sb=new StringBuilder(getString(R.string.chat_specify_details));
      sb.append(Tools.LineSep);
      for (      Contact contact : contacts) {
        sb.append(contact.name);
        sb.append(Tools.LineSep);
      }
      send(sb.toString());
    }
 else     if (contacts.size() == 1) {
      Contact contact=contacts.get(0);
      send(R.string.chat_del_sms_from,contact.name);
      nbDeleted=mSmsManager.deleteSmsByContact(contact.rawIds);
    }
 else {
      send(R.string.chat_no_match_for,search);
    }
  }
 else   if (cmd.equals("number") && search != null) {
    send(R.string.chat_del_sms_from,search);
    nbDeleted=mSmsManager.deleteSmsByNumber(search);
    if (nbDeleted <= 0) {
      send(R.string.chat_no_match_for,search);
    }
  }
 else {
    send(R.string.chat_del_sms_syntax);
  }
  if (nbDeleted >= 0) {
    send(R.string.chat_del_sms_nb,nbDeleted);
  }
 else   if (nbDeleted == -1) {
    send(R.string.chat_del_sms_error);
  }
}

private void deleteSMS ( String cmd , String search ) { int nbDeleted = - 2 ; if ( cmd . equals ( "all" ) ) { nbDeleted = mSmsManager . deleteAllSms ( ) ; } else if ( cmd . equals ( "sent" ) ) { nbDeleted = mSmsManager . deleteSentSms ( ) ; } else if ( cmd . startsWith ( "last" ) ) { Integer number = Tools . parseInt ( search ) ; if ( number == null ) { number = 1 ; } if ( cmd . equals ( "last" ) ) { nbDeleted = mSmsManager . deleteLastSms ( number ) ; } else if ( cmd . equals ( "lastin" ) ) { nbDeleted = mSmsManager . deleteLastInSms ( number ) ; } else if ( cmd . equals ( "lastout" ) ) { nbDeleted = mSmsManager . deleteLastOutSms ( number ) ; } else { send ( R . string . chat_del_sms_error ) ; } } else if ( cmd . equals ( "contact" ) && search != null ) { ArrayList < Contact > contacts = ContactsManager . getMatchingContacts ( sContext , search ) ; if ( contacts . size ( ) > 1 ) { StringBuilder sb = new StringBuilder ( getString ( R . string . chat_specify_details ) ) ; sb . append ( Tools . LineSep ) ; for ( Contact contact : contacts ) { sb . append ( contact . name ) ; sb . append ( Tools . LineSep ) ; } send ( sb . toString ( ) ) ; } else if ( contacts . size ( ) == 1 ) { Contact contact = contacts . get ( 0 ) ; send ( R . string . chat_del_sms_from , contact . name ) ; nbDeleted = mSmsManager . deleteSmsByContact ( contact . rawIds ) ; } else { send ( R . string . chat_no_match_for , search ) ; } } else if ( cmd . equals ( "number" ) && search != null ) { send ( R . string . chat_del_sms_from , search ) ; nbDeleted = mSmsManager . deleteSmsByNumber ( search ) ; if ( nbDeleted <= 0 ) { send ( R . string . chat_no_match_for , search ) ; } } else { send ( R . string . chat_del_sms_syntax ) ; } if ( nbDeleted >= 0 ) { send ( R . string . chat_del_sms_nb , nbDeleted ) ; } else if ( nbDeleted == - 1 ) { send ( R . string . chat_del_sms_error ) ; } }
" delsms " cmd deletes sms , either - all sms - all sent sms - sms from specified contact - # last messages - # last incoming / outgoing messages
