public void startAddContactTask(String id) {
    if (db.contactAlreadyExists(id)) {
      onAddContactTaskFailed();
      return;
    }

    encryptor = new EncryptionDES();

    AddContactRequest request = new AddContactRequest();
    request.setId(encryptor.encrypt(id));

    AddContactTask addContactTask = new AddContactTask(connection, addContactTaskListener);
    addContactTask.execute(request);
  }
  public void onAddContactTaskFinished(AddContactResponse response) {
    State state = State.ERROR;
    if (response == null) {
      state = State.ERROR;
    } else {
      Log.d("AddContactResponse", "AddContactResponse is: \n" + response.toString());
      if (response.isError()) state = State.FAILED;
      else {
        ContactStub contact_stub = response.getContact();
        contact_stub.setEmail(encryptor.decrypt(contact_stub.getEmail()));
        contact_stub.setName(encryptor.decrypt(contact_stub.getName()));
        if (contact_stub != null) {
          Contact contact = new Contact(contact_stub);
          if (db.insertContact(contact.toContentValues())) {
            state = State.SUCCESS;

          } else state = State.ERROR;
        } else state = State.FAILED;
      }
    }
    fragment.onAddContactTaskFinished(state);
  }