@Override
        public void run() {
          String[] joinOptions;
          String subject = null;
          String nickName = null;

          nickName =
              ConfigurationUtils.getChatRoomProperty(
                  chatRoomWrapper.getParentProvider().getProtocolProvider(),
                  chatRoomWrapper.getChatRoomID(),
                  "userNickName");
          if (nickName == null) {
            joinOptions =
                ChatRoomJoinOptionsDialog.getJoinOptions(
                    chatRoomWrapper.getParentProvider().getProtocolProvider(),
                    chatRoomWrapper.getChatRoomID(),
                    MUCActivator.getMUCService()
                        .getDefaultNickname(
                            chatRoomWrapper.getParentProvider().getProtocolProvider()));
            nickName = joinOptions[0];
            subject = joinOptions[1];
          }

          if (nickName != null)
            MUCActivator.getMUCService().joinChatRoom(chatRoomWrapper, nickName, null, subject);
        }
 @Override
 public void run() {
   String[] joinOptions;
   joinOptions =
       ChatRoomJoinOptionsDialog.getJoinOptions(
           chatRoomWrapper.getParentProvider().getProtocolProvider(),
           chatRoomWrapper.getChatRoomID(),
           MUCActivator.getMUCService()
               .getDefaultNickname(chatRoomWrapper.getParentProvider().getProtocolProvider()));
   if (joinOptions[0] == null) return;
   MUCActivator.getMUCService()
       .joinChatRoom(chatRoomWrapper, joinOptions[0], null, joinOptions[1]);
 }
      @Override
      public void run() {
        ChatRoom chatRoom = chatRoomWrapper.getChatRoom();

        if (chatRoom != null) {
          ChatRoomWrapper leavedRoomWrapped =
              MUCActivator.getMUCService().leaveChatRoom(chatRoomWrapper);
          if (leavedRoomWrapped != null)
            MUCActivator.getUIService().closeChatRoomWindow(leavedRoomWrapped);
        }

        MUCActivator.getUIService().closeChatRoomWindow(chatRoomWrapper);

        MUCActivator.getMUCService().removeChatRoom(chatRoomWrapper);
      }
예제 #4
0
  /**
   * Creates an instance of <tt>ChatRoomQuery</tt> by specifying the parent contact source, the
   * query string to match and the maximum result contacts to return.
   *
   * @param queryString the query string to match
   * @param contactSource the parent contact source
   */
  public ChatRoomQuery(String queryString, ChatRoomContactSourceService contactSource) {
    super(
        contactSource,
        Pattern.compile(queryString, Pattern.CASE_INSENSITIVE | Pattern.LITERAL),
        true);
    this.queryString = queryString;

    mucService = MUCActivator.getMUCService();
  }
 @Override
 public void run() {
   ChatRoomJoinOptionsDialog.getJoinOptions(
       true,
       chatRoomWrapper.getParentProvider().getProtocolProvider(),
       chatRoomWrapper.getChatRoomID(),
       MUCActivator.getMUCService()
           .getDefaultNickname(chatRoomWrapper.getParentProvider().getProtocolProvider()));
 }
    /**
     * Checks if the menu item should be enabled or disabled.
     *
     * @param contact the contact associated with the menu item.
     * @return <tt>true</tt> if the item should be enabled and <tt>false</tt> if not.
     */
    public boolean check(SourceContact contact) {
      ChatRoomWrapper chatRoomWrapper =
          MUCActivator.getMUCService().findChatRoomWrapperFromSourceContact(contact);
      ChatRoom chatRoom = null;
      if (chatRoomWrapper != null) {
        chatRoom = chatRoomWrapper.getChatRoom();
      }

      if ((chatRoom != null) && chatRoom.isJoined()) return false;
      return true;
    }
    @Override
    public boolean isVisible(SourceContact actionSource) {
      if (!(actionSource instanceof ChatRoomSourceContact)) return false;

      if (name.equals("autojoin") || name.equals("autojoin_pressed")) {
        ChatRoomSourceContact contact = (ChatRoomSourceContact) actionSource;
        ChatRoomWrapper room =
            MUCActivator.getMUCService().findChatRoomWrapperFromSourceContact(contact);
        if (name.equals("autojoin")) return !room.isAutojoin();

        if (name.equals("autojoin_pressed")) return room.isAutojoin();
      }
      return true;
    }
예제 #8
0
  /**
   * Handles chat room presence status updates.
   *
   * @param evt the <tt>LocalUserChatRoomPresenceChangeEvent</tt> instance containing the chat room
   *     and the type, and reason of the change
   */
  @Override
  public void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt) {
    ChatRoom sourceChatRoom = evt.getChatRoom();

    String eventType = evt.getEventType();

    boolean existingContact = false;
    ChatRoomSourceContact foundContact = null;
    synchronized (contactResults) {
      for (ChatRoomSourceContact contact : contactResults) {
        if (contactEqualsChatRoom(contact, sourceChatRoom)) {
          existingContact = true;
          foundContact = contact;
          contactResults.remove(contact);
          break;
        }
      }
    }

    if (LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED.equals(eventType)) {
      if (existingContact) {
        foundContact.setPresenceStatus(ChatRoomPresenceStatus.CHAT_ROOM_ONLINE);
        synchronized (contactResults) {
          contactResults.add(foundContact);
        }
        fireContactChanged(foundContact);
      } else {
        ChatRoomWrapper chatRoom =
            MUCActivator.getMUCService().findChatRoomWrapperFromChatRoom(sourceChatRoom);
        if (chatRoom != null) addChatRoom(sourceChatRoom, false, chatRoom.isAutojoin());
      }
    } else if ((LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_LEFT.equals(eventType)
        || LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_KICKED.equals(eventType)
        || LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_DROPPED.equals(eventType))) {
      if (existingContact) {
        foundContact.setPresenceStatus(ChatRoomPresenceStatus.CHAT_ROOM_OFFLINE);
        synchronized (contactResults) {
          contactResults.add(foundContact);
        }
        fireContactChanged(foundContact);
      }
    }
  }
    @Override
    public boolean isVisible(SourceContact actionSource) {
      if (actionSource instanceof ChatRoomSourceContact) {
        if (name.equals("leave")) {
          return actionsEnabledCheckers[3].check(actionSource);
        } else if (name.equals("join")) {
          return actionsEnabledCheckers[1].check(actionSource);
        } else {
          ChatRoomSourceContact contact = (ChatRoomSourceContact) actionSource;
          ChatRoomWrapper room =
              MUCActivator.getMUCService().findChatRoomWrapperFromSourceContact(contact);
          if (room == null) return false;

          if (name.equals("autojoin")) return room.isAutojoin();
          else if (name.equals("autojoin_pressed")) return !room.isAutojoin();
        }
      }
      return false;
    }
 /**
  * Sets the source contact.
  *
  * @param contact the contact to set
  */
 public void setContact(SourceContact contact) {
   this.contact = contact;
   chatRoomWrapper = MUCActivator.getMUCService().findChatRoomWrapperFromSourceContact(contact);
 }
 @Override
 public boolean isSelected(SourceContact contact) {
   ChatRoomWrapper chatRoomWrapper =
       MUCActivator.getMUCService().findChatRoomWrapperFromSourceContact(contact);
   return chatRoomWrapper.isAutojoin();
 }
 @Override
 public void run() {
   MUCActivator.getMUCService().openChatRoom(chatRoomWrapper);
 }