    public ChatRoomImpl(String jid, String participantNickname, String title) {
        this.participantJID = jid;
        roster = SparkManager.getConnection().getRoster();
        Iterator<Presence> presences = roster.getPresences(jid);
        int count = 0;
        Presence p = null;
        if (presences.hasNext()) {
            p = presences.next();
            count++;
        }
        if(count == 1 && p != null && p.getFrom() != null){
            participantJID = p.getFrom();
        }
        this.participantNickname = participantNickname;
        loadHistory();
        PacketFilter fromFilter = new FromJIDFilter(participantJID);
        PacketFilter orFilter = new OrFilter(new PacketTypeFilter(Presence.class), new PacketTypeFilter(Message.class));
        PacketFilter andFilter = new AndFilter(orFilter, fromFilter);
        SparkManager.getConnection().addPacketListener(this, andFilter);
        this.roomname = jid;
        this.tabTitle = title;
        final SimpleDateFormat formatter = new SimpleDateFormat("h:mm a");
        this.roomTitle = participantNickname;
        this.getSplitPane().setRightComponent(null);
        getSplitPane().setDividerSize(0);
        presence = PresenceManager.getPresence(participantJID);
        RosterEntry entry = roster.getEntry(participantJID);
        tabIcon = PresenceManager.getIconFromPresence(presence);
        ChatRoomButton infoButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24));
        infoButton.setToolTipText(Res.getString("message.view.information.about.this.user"));
        getToolBar().addChatRoomButton(infoButton);
        if (entry == null && !StringUtils.parseResource(participantJID).equals(participantNickname)) {
            ChatRoomButton addToRosterButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.ADD_IMAGE_24x24));
            addToRosterButton.setToolTipText(Res.getString("message.add.this.user.to.your.roster"));
            getToolBar().addChatRoomButton(addToRosterButton);
            addToRosterButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    RosterDialog rosterDialog = new RosterDialog();
                    rosterDialog.setDefaultJID(participantJID);
                    rosterDialog.setDefaultNickname(getParticipantNickname());
                    rosterDialog.showRosterDialog(SparkManager.getChatManager().getChatContainer().getChatFrame());
                }
            });
        }
        infoButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                VCardManager vcard = SparkManager.getVCardManager();
                vcard.viewProfile(participantJID, SparkManager.getChatManager().getChatContainer());
            }
        });
        if (StringUtils.parseResource(participantJID).equals(participantNickname)) {
            getToolBar().setVisible(false);
        }
        typingTimerTask = new TimerTask() {
            public void run() {
                if (!sendTypingNotification) {
                    return;
                }
                long now = System.currentTimeMillis();
                if (now - lastTypedCharTime > 2000) {
                    if (!sendNotification) {
                        SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID);
                        sendNotification = true;
                    }
                }
            }
        };
        TaskEngine.getInstance().scheduleAtFixedRate(typingTimerTask, 2000, 2000);
        lastActivity = System.currentTimeMillis();
    }

    public ChatRoomImpl(final String jid, String participantNickname, String title) {
        this.participantJID = jid;
        roster = SparkManager.getConnection().getRoster();
        Iterator<Presence> presences = roster.getPresences(jid);
        int count = 0;
        Presence p = null;
        if (presences.hasNext()) {
            p = presences.next();
            count++;
        }
        if(count == 1 && p != null && p.getFrom() != null){
            participantJID = p.getFrom();
        }
        this.participantNickname = participantNickname;
        loadHistory();
        PacketFilter fromFilter = new FromJIDFilter(jid);
        PacketFilter orFilter = new OrFilter(new PacketTypeFilter(Presence.class), new PacketTypeFilter(Message.class));
        PacketFilter andFilter = new AndFilter(orFilter, fromFilter);
        SparkManager.getConnection().addPacketListener(this, andFilter);
        this.roomname = jid;
        this.tabTitle = title;
        final SimpleDateFormat formatter = new SimpleDateFormat("h:mm a");
        this.roomTitle = participantNickname;
        this.getSplitPane().setRightComponent(null);
        getSplitPane().setDividerSize(0);
        presence = PresenceManager.getPresence(participantJID);
        RosterEntry entry = roster.getEntry(jid);
        tabIcon = PresenceManager.getIconFromPresence(presence);
        ChatRoomButton infoButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24));
        infoButton.setToolTipText(Res.getString("message.view.information.about.this.user"));
        getToolBar().addChatRoomButton(infoButton);
        if (entry == null && !StringUtils.parseResource(participantJID).equals(participantNickname)) {
            ChatRoomButton addToRosterButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.ADD_IMAGE_24x24));
            addToRosterButton.setToolTipText(Res.getString("message.add.this.user.to.your.roster"));
            getToolBar().addChatRoomButton(addToRosterButton);
            addToRosterButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    RosterDialog rosterDialog = new RosterDialog();
                    rosterDialog.setDefaultJID(jid);
                    rosterDialog.setDefaultNickname(getParticipantNickname());
                    rosterDialog.showRosterDialog(SparkManager.getChatManager().getChatContainer().getChatFrame());
                }
            });
        }
        infoButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                VCardManager vcard = SparkManager.getVCardManager();
                vcard.viewProfile(jid, SparkManager.getChatManager().getChatContainer());
            }
        });
        if (StringUtils.parseResource(participantJID).equals(participantNickname)) {
            getToolBar().setVisible(false);
        }
        typingTimerTask = new TimerTask() {
            public void run() {
                if (!sendTypingNotification) {
                    return;
                }
                long now = System.currentTimeMillis();
                if (now - lastTypedCharTime > 2000) {
                    if (!sendNotification) {
                        SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID);
                        sendNotification = true;
                    }
                }
            }
        };
        TaskEngine.getInstance().scheduleAtFixedRate(typingTimerTask, 2000, 2000);
        lastActivity = System.currentTimeMillis();
    }
