private void notifyFriendsRoomUpdate(QBDialog dialog, List<Integer> friendIdsList) {
   for (Integer friendId : friendIdsList) {
     try {
       notifyFriendOnUpdateChat(dialog, friendId);
     } catch (QBResponseException responseException) {
       ErrorUtils.logError(responseException);
     } catch (SmackException.NotConnectedException e) {
       ErrorUtils.logError(e);
     } catch (XMPPException e) {
       ErrorUtils.logError(e);
     }
   }
 }
 private void sendRoomMessage(QBChatMessage chatMessage, String roomJId, String dialogId)
     throws QBResponseException {
   groupChat = groupChatManager.getGroupChat(roomJId);
   QBDialog existingDialog = null;
   if (groupChat == null) {
     existingDialog = ChatUtils.getExistDialogById(context, dialogId);
     groupChat = (QBGroupChat) createChatLocally(existingDialog, null);
   }
   String error = null;
   if (!TextUtils.isEmpty(dialogId)) {
     chatMessage.setProperty(ChatUtils.PROPERTY_DIALOG_ID, dialogId);
   }
   try {
     groupChat.sendMessage(chatMessage);
   } catch (XMPPException e) {
     error = context.getString(R.string.dlg_fail_send_msg);
   } catch (SmackException.NotConnectedException e) {
     error = context.getString(R.string.dlg_fail_connection);
   } catch (IllegalStateException e) {
     ErrorUtils.showError(context, context.getString(R.string.dlg_not_joined_room));
     tryJoinRoomChat(existingDialog);
   }
   if (error != null) {
     throw new QBResponseException(error);
   }
 }
 private void tryJoinRoomChat(QBDialog dialog) {
   try {
     joinRoomChat(dialog);
   } catch (Exception e) {
     ErrorUtils.logError(e);
   }
 }
 private QBGroupChat createChatIfNotExist(QBDialog dialog) throws QBResponseException {
   boolean notNull = Utils.validateNotNull(groupChatManager);
   if (!notNull) {
     ErrorUtils.logError(TAG, " groupChatManager is NULL");
     throw new QBResponseException(context.getString(R.string.dlg_fail_create_chat));
   }
   groupChat = groupChatManager.getGroupChat(dialog.getRoomJid());
   if (groupChat == null) {
     groupChat = groupChatManager.createGroupChat(dialog.getRoomJid());
     groupChat.addMessageListener(roomChatMessageListener);
   }
   return groupChat;
 }
  private boolean subscribeToPushNotifications(String regId) {
    String deviceId = getDeviceIdForMobile(activityRef.get());
    if (deviceId == null) {
      deviceId = getDeviceIdForTablet(activityRef.get());
    }

    ArrayList<QBSubscription> subscriptions = null;
    try {
      subscriptions =
          QBMessages.subscribeToPushNotificationsTask(regId, deviceId, QBEnvironment.PRODUCTION);
    } catch (QBResponseException e) {
      ErrorUtils.logError(e);
    }
    return subscriptions != null;
  }
  public void sendOccupantStatusGroup(String sendStr) {
    long time = DateUtilsCore.getCurrentTime();

    QBChatMessage chatMessage = new QBChatMessage();
    chatMessage.setBody(sendStr);
    chatMessage.setProperty(
        ChatUtils.PROPERTY_NOTIFICATION_TYPE, ChatUtils.PROPERTY_NOTIFICATION_TYPE_CREATE_CHAT);
    chatMessage.setProperty(ChatUtils.PROPERTY_DIALOG_ID, currentDialog.getDialogId());
    chatMessage.setProperty(ChatUtils.PROPERTY_ROOM_JID, currentDialog.getRoomJid());
    chatMessage.setProperty(
        ChatUtils.PROPERTY_OCCUPANTS_IDS,
        TextUtils.join(ChatUtils.OCCUPANT_IDS_DIVIDER, currentDialog.getOccupants()));
    chatMessage.setProperty(ChatUtils.PROPERTY_ROOM_NAME, currentDialog.getName());
    chatMessage.setProperty(
        ChatUtils.PROPERTY_DIALOG_TYPE_CODE, String.valueOf(currentDialog.getType().getCode()));
    chatMessage.setProperty(ChatUtils.PROPERTY_DATE_SENT, time + ConstsCore.EMPTY_STRING);
    chatMessage.setProperty(ChatUtils.PROPERTY_SAVE_TO_HISTORY, ChatUtils.VALUE_SAVE_TO_HISTORY);

    try {
      sendRoomMessage(chatMessage, currentDialog.getRoomJid(), currentDialog.getDialogId());
    } catch (QBResponseException e) {
      ErrorUtils.showError(context, e);
    }
  }