mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
someclean up in MessageContentViewer
This commit is contained in:
parent
3892cfb5fb
commit
6dcc20a80e
@ -94,7 +94,6 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
public MessageContentViewer() {
|
public MessageContentViewer() {
|
||||||
initComponents();
|
initComponents();
|
||||||
drp = DataResultPanel.createInstanceUninitialized("Attachments", "", Node.EMPTY, 0, null);
|
drp = DataResultPanel.createInstanceUninitialized("Attachments", "", Node.EMPTY, 0, null);
|
||||||
|
|
||||||
attachmentsScrollPane.setViewportView(drp);
|
attachmentsScrollPane.setViewportView(drp);
|
||||||
msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX, true);
|
msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX, true);
|
||||||
|
|
||||||
@ -346,7 +345,7 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
private void showImagesToggleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showImagesToggleButtonActionPerformed
|
private void showImagesToggleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showImagesToggleButtonActionPerformed
|
||||||
try {
|
try {
|
||||||
String htmlText = getAttributeValueSafe(artifact, TSK_EMAIL_CONTENT_HTML);
|
String htmlText = getAttributeValueSafe(artifact, TSK_EMAIL_CONTENT_HTML);
|
||||||
if (!htmlText.isEmpty()) {
|
if (false == htmlText.isEmpty()) {
|
||||||
if (showImagesToggleButton.isSelected()) {
|
if (showImagesToggleButton.isSelected()) {
|
||||||
showImagesToggleButton.setText(Bundle.MessageContentViewer_showImagesToggleButton_hide_text());
|
showImagesToggleButton.setText(Bundle.MessageContentViewer_showImagesToggleButton_hide_text());
|
||||||
this.htmlbodyTextPane.setText(wrapInHtmlBody(htmlText));
|
this.htmlbodyTextPane.setText(wrapInHtmlBody(htmlText));
|
||||||
@ -457,6 +456,7 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
rtfbodyTextPane.setText("");
|
rtfbodyTextPane.setText("");
|
||||||
htmlbodyTextPane.setText("");
|
htmlbodyTextPane.setText("");
|
||||||
textbodyTextArea.setText("");
|
textbodyTextArea.setText("");
|
||||||
|
drp.setNode(null);
|
||||||
msgbodyTabbedPane.setEnabled(false);
|
msgbodyTabbedPane.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,8 +464,8 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
public boolean isSupported(Node node) {
|
public boolean isSupported(Node node) {
|
||||||
BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class);
|
BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class);
|
||||||
return ((artifact != null)
|
return ((artifact != null)
|
||||||
&& ((artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID())
|
&& ((artifact.getArtifactTypeID() == TSK_EMAIL_MSG.getTypeID())
|
||||||
|| (artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID())));
|
|| (artifact.getArtifactTypeID() == TSK_MESSAGE.getTypeID())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -476,53 +476,39 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void configureTextArea(BlackboardAttribute.ATTRIBUTE_TYPE type, int index) throws TskCoreException {
|
/**
|
||||||
|
* Configure the text area at the given index to show the content of the
|
||||||
|
* given type.
|
||||||
|
*
|
||||||
|
* @param type The ATTRIBUT_TYPE to show in the indexed tab.
|
||||||
|
* @param index The index of the text area to configure.
|
||||||
|
*
|
||||||
|
* @throws TskCoreException
|
||||||
|
*/
|
||||||
|
private void configureTextArea(BlackboardAttribute.ATTRIBUTE_TYPE type, int index) throws TskCoreException {
|
||||||
String attributeText = getAttributeValueSafe(artifact, type);
|
String attributeText = getAttributeValueSafe(artifact, type);
|
||||||
if (!attributeText.isEmpty()) {
|
|
||||||
attributeText = (index == HTML_TAB_INDEX)
|
if (index == HTML_TAB_INDEX) {
|
||||||
? wrapInHtmlBody(cleanseHTML(attributeText))
|
//special case for HTML, we need to 'cleanse' it
|
||||||
: attributeText;
|
attributeText = wrapInHtmlBody(cleanseHTML(attributeText));
|
||||||
final JTextComponent textComponent = textAreas.get(index);
|
|
||||||
textComponent.setText(attributeText);
|
|
||||||
textComponent.setCaretPosition(0);
|
|
||||||
msgbodyTabbedPane.setEnabledAt(index, true);
|
|
||||||
msgbodyTabbedPane.setSelectedIndex(index);
|
|
||||||
} else {
|
|
||||||
msgbodyTabbedPane.setEnabledAt(index, false);
|
|
||||||
}
|
}
|
||||||
|
JTextComponent textComponent = textAreas.get(index);
|
||||||
|
textComponent.setText(attributeText);
|
||||||
|
final boolean hasText = attributeText.length() > 0;
|
||||||
|
|
||||||
|
if (hasText) {
|
||||||
|
textComponent.setCaretPosition(0); //make sure we start at the top
|
||||||
|
msgbodyTabbedPane.setSelectedIndex(index);
|
||||||
|
}
|
||||||
|
msgbodyTabbedPane.setEnabledAt(index, hasText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayEmailMsg() {
|
private void enableCommonFields() {
|
||||||
msgbodyTabbedPane.setEnabled(true);
|
msgbodyTabbedPane.setEnabled(true);
|
||||||
fromLabel.setEnabled(true);
|
fromLabel.setEnabled(true);
|
||||||
toLabel.setEnabled(true);
|
toLabel.setEnabled(true);
|
||||||
ccLabel.setEnabled(true);
|
|
||||||
subjectLabel.setEnabled(true);
|
subjectLabel.setEnabled(true);
|
||||||
datetimeText.setEnabled(true);
|
datetimeText.setEnabled(true);
|
||||||
|
|
||||||
directionText.setEnabled(false);
|
|
||||||
|
|
||||||
showImagesToggleButton.setText("Show Images");
|
|
||||||
showImagesToggleButton.setSelected(false);
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.fromText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
|
|
||||||
this.toText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
|
|
||||||
this.directionText.setText("");
|
|
||||||
this.ccText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
|
|
||||||
this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
|
|
||||||
this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME_RCVD));
|
|
||||||
|
|
||||||
configureTextArea(TSK_HEADERS, HDR_TAB_INDEX);
|
|
||||||
configureTextArea(TSK_EMAIL_CONTENT_PLAIN, TEXT_TAB_INDEX);
|
|
||||||
configureTextArea(TSK_EMAIL_CONTENT_HTML, HTML_TAB_INDEX);
|
|
||||||
configureTextArea(TSK_EMAIL_CONTENT_RTF, RTF_TAB_INDEX);
|
|
||||||
|
|
||||||
configureAttachments();
|
|
||||||
|
|
||||||
} catch (TskCoreException ex) {
|
|
||||||
LOGGER.log(Level.WARNING, "Failed to get attributes for email message.", ex); //NON-NLS
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureAttachments() throws TskCoreException {
|
private void configureAttachments() throws TskCoreException {
|
||||||
@ -543,14 +529,37 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
return "<html><body>" + htmlText + "</body></html>";
|
return "<html><body>" + htmlText + "</body></html>";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayMsg() {
|
private void displayEmailMsg() {
|
||||||
msgbodyTabbedPane.setEnabled(true);
|
enableCommonFields();
|
||||||
fromLabel.setEnabled(true);
|
|
||||||
toLabel.setEnabled(true);
|
|
||||||
subjectLabel.setEnabled(true);
|
|
||||||
directionText.setEnabled(true);
|
|
||||||
datetimeText.setEnabled(true);
|
|
||||||
|
|
||||||
|
directionText.setEnabled(false);
|
||||||
|
ccLabel.setEnabled(true);
|
||||||
|
|
||||||
|
showImagesToggleButton.setText("Show Images");
|
||||||
|
showImagesToggleButton.setSelected(false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.fromText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
|
||||||
|
this.toText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
|
||||||
|
this.directionText.setText("");
|
||||||
|
this.ccText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
|
||||||
|
this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
|
||||||
|
this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME_RCVD));
|
||||||
|
|
||||||
|
configureTextArea(TSK_HEADERS, HDR_TAB_INDEX);
|
||||||
|
configureTextArea(TSK_EMAIL_CONTENT_PLAIN, TEXT_TAB_INDEX);
|
||||||
|
configureTextArea(TSK_EMAIL_CONTENT_HTML, HTML_TAB_INDEX);
|
||||||
|
configureTextArea(TSK_EMAIL_CONTENT_RTF, RTF_TAB_INDEX);
|
||||||
|
configureAttachments();
|
||||||
|
} catch (TskCoreException ex) {
|
||||||
|
LOGGER.log(Level.WARNING, "Failed to get attributes for email message.", ex); //NON-NLS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayMsg() {
|
||||||
|
enableCommonFields();
|
||||||
|
|
||||||
|
directionText.setEnabled(true);
|
||||||
ccLabel.setEnabled(false);
|
ccLabel.setEnabled(false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -572,7 +581,7 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getAttributeValueSafe(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE type) throws TskCoreException {
|
private static String getAttributeValueSafe(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE type) throws TskCoreException {
|
||||||
return Optional.ofNullable(artifact.getAttribute(new BlackboardAttribute.Type(type)))
|
return Optional.ofNullable(artifact.getAttribute(new BlackboardAttribute.Type(type)))
|
||||||
.map(BlackboardAttribute::getDisplayString)
|
.map(BlackboardAttribute::getDisplayString)
|
||||||
.orElse("");
|
.orElse("");
|
||||||
@ -597,10 +606,10 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
|
|
||||||
private static class AttachmentsChildren extends Children.Keys<AbstractFile> {
|
private static class AttachmentsChildren extends Children.Keys<AbstractFile> {
|
||||||
|
|
||||||
private final Set<AbstractFile> files;
|
private final Set<AbstractFile> attachments;
|
||||||
|
|
||||||
AttachmentsChildren(Set<AbstractFile> collect) {
|
AttachmentsChildren(Set<AbstractFile> attachments) {
|
||||||
this.files = collect;
|
this.attachments = attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -611,17 +620,20 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
@Override
|
@Override
|
||||||
protected void addNotify() {
|
protected void addNotify() {
|
||||||
super.addNotify();
|
super.addNotify();
|
||||||
setKeys(files);
|
setKeys(attachments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension of FileNode customized for viewing attachments in the
|
||||||
|
* MessageContentViewer. It overrides createSheet() to customize what
|
||||||
|
* properties are shown in the table, and could also override getActions(),
|
||||||
|
* getPreferedAction(), etc.
|
||||||
|
*/
|
||||||
private static class AttachmentNode extends FileNode {
|
private static class AttachmentNode extends FileNode {
|
||||||
|
|
||||||
private final AbstractFile file;
|
|
||||||
|
|
||||||
AttachmentNode(AbstractFile file) {
|
AttachmentNode(AbstractFile file) {
|
||||||
super(file, true);
|
super(file, true);
|
||||||
this.file = file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -632,7 +644,7 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
ss = Sheet.createPropertiesSet();
|
ss = Sheet.createPropertiesSet();
|
||||||
s.put(ss);
|
s.put(ss);
|
||||||
}
|
}
|
||||||
|
AbstractFile file = getContent();
|
||||||
ss.put(new NodeProperty<>("Name", "Name", "Name", file.getName()));
|
ss.put(new NodeProperty<>("Name", "Name", "Name", file.getName()));
|
||||||
ss.put(new NodeProperty<>("Size", "Size", "Size", file.getSize()));
|
ss.put(new NodeProperty<>("Size", "Size", "Size", file.getSize()));
|
||||||
ss.put(new NodeProperty<>("Mime Type", "Mime Type", "Mime Type", StringUtils.defaultString(file.getMIMEType())));
|
ss.put(new NodeProperty<>("Mime Type", "Mime Type", "Mime Type", StringUtils.defaultString(file.getMIMEType())));
|
||||||
@ -641,6 +653,5 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont
|
|||||||
addTagProperty(ss);
|
addTagProperty(ss);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user