public String[] getParticipants() {
    if (mIsGroupChat) {
      Contact self = mConnection.getLoginUser();
      ChatGroup group = (ChatGroup) mChatSession.getParticipant();
      List<Contact> members = group.getMembers();
      String[] result = new String[members.size() - 1];
      int index = 0;
      for (Contact c : members) {
        if (!c.equals(self)) {
          result[index++] = c.getAddress().getAddress();
        }
      }
      return result;
    } else {

      return new String[] {mChatSession.getParticipant().getAddress().getAddress()};
    }
  }
  private long insertOrUpdateGroupContactInDb(ChatGroup group) {
    // Insert a record in contacts table
    ContentValues values = new ContentValues(4);
    values.put(Imps.Contacts.USERNAME, group.getAddress().getAddress());
    values.put(Imps.Contacts.NICKNAME, group.getName());
    values.put(Imps.Contacts.CONTACTLIST, ContactListManagerAdapter.LOCAL_GROUP_LIST_ID);
    values.put(Imps.Contacts.TYPE, Imps.Contacts.TYPE_GROUP);

    Uri contactUri =
        ContentUris.withAppendedId(
            ContentUris.withAppendedId(Imps.Contacts.CONTENT_URI, mConnection.mProviderId),
            mConnection.mAccountId);

    ContactListManagerAdapter listManager =
        (ContactListManagerAdapter) mConnection.getContactListManager();

    long id = listManager.queryGroup(group);

    if (id == -1) {
      id = ContentUris.parseId(mContentResolver.insert(contactUri, values));

      ArrayList<ContentValues> memberValues = new ArrayList<ContentValues>();
      Contact self = mConnection.getLoginUser();
      for (Contact member : group.getMembers()) {
        if (!member.equals(self)) { // avoid to insert the user himself
          ContentValues memberValue = new ContentValues(2);
          memberValue.put(Imps.GroupMembers.USERNAME, member.getAddress().getAddress());
          memberValue.put(Imps.GroupMembers.NICKNAME, member.getName());
          memberValues.add(memberValue);
        }
      }
      if (!memberValues.isEmpty()) {
        ContentValues[] result = new ContentValues[memberValues.size()];
        memberValues.toArray(result);
        Uri memberUri = ContentUris.withAppendedId(Imps.GroupMembers.CONTENT_URI, id);
        mContentResolver.bulkInsert(memberUri, result);
      }
    }

    return id;
  }