use of org.jivesoftware.sparkimpl.plugin.transcripts.ChatTranscript in project Spark by igniterealtime.
the class ChatRoomImpl method loadHistory.
protected void loadHistory() {
// Add VCard Panel
vcardPanel = new VCardPanel(participantJID.asBareJid());
getToolBar().add(vcardPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 2, 0, 2), 0, 0));
if (!Default.getBoolean(Default.HISTORY_DISABLED) && Enterprise.containsFeature(Enterprise.HISTORY_TRANSCRIPTS_FEATURE)) {
final LocalPreferences localPreferences = SettingsManager.getLocalPreferences();
if (!localPreferences.isChatHistoryEnabled()) {
return;
}
if (!localPreferences.isPrevChatHistoryEnabled()) {
return;
}
final ChatTranscript chatTranscript = ChatTranscripts.getCurrentChatTranscript(getParticipantJID());
final String personalNickname = SparkManager.getUserManager().getNickname();
for (HistoryMessage message : chatTranscript.getMessages()) {
String nickname = SparkManager.getUserManager().getUserNicknameFromJID(message.getFrom().asBareJid());
String messageBody = message.getBody();
if (nickname.equals(message.getFrom().toString()) || nickname.equals(message.getFrom().asBareJid().toString())) {
BareJid otherJID = message.getFrom().asBareJid();
EntityBareJid myJID = SparkManager.getSessionManager().getUserBareAddress();
if (otherJID.equals(myJID)) {
nickname = personalNickname;
} else {
Resourcepart resourcepart = message.getFrom().getResourceOrNull();
if (resourcepart == null) {
Localpart localpart = message.getFrom().getLocalpartOrNull();
if (localpart != null) {
nickname = localpart.toString();
}
} else {
nickname = resourcepart.toString();
}
}
}
if (ModelUtil.hasLength(messageBody) && messageBody.startsWith("/me ")) {
messageBody = messageBody.replaceFirst("/me", nickname);
}
final Date messageDate = message.getDate();
getTranscriptWindow().insertHistoryMessage(nickname, messageBody, messageDate);
}
if (0 < chatTranscript.getMessages().size()) {
// Check if we have history mesages
getTranscriptWindow().insertHorizontalLine();
}
chatTranscript.release();
}
}
Aggregations