mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
cleaned up ImageAnalyzerModule
This commit is contained in:
parent
0f76be8386
commit
cda1fbcc46
@ -430,7 +430,7 @@ public final class ImageAnalyzerController {
|
|||||||
setCase(newCase); //connect db, groupmanager, start worker thread
|
setCase(newCase); //connect db, groupmanager, start worker thread
|
||||||
} else { // case is closing
|
} else { // case is closing
|
||||||
//close window, reset everything
|
//close window, reset everything
|
||||||
SwingUtilities.invokeLater(ImageAnalyzerModule::closeTopComponent);
|
SwingUtilities.invokeLater(ImageAnalyzerTopComponent::closeTopComponent);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -28,50 +28,52 @@ import java.util.Set;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openide.windows.Mode;
|
|
||||||
import org.openide.windows.TopComponent;
|
|
||||||
import org.openide.windows.WindowManager;
|
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.coreutils.ImageUtils;
|
import org.sleuthkit.autopsy.coreutils.ImageUtils;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
|
|
||||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableDB;
|
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableDB;
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
import org.sleuthkit.datamodel.AbstractFile;
|
||||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
import org.sleuthkit.datamodel.TskData;
|
import org.sleuthkit.datamodel.TskData;
|
||||||
|
|
||||||
/** static definitions and utilities for the ImageAnalyzer module
|
/** static definitions and utilities for the ImageAnalyzer module */
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ImageAnalyzerModule {
|
public class ImageAnalyzerModule {
|
||||||
|
|
||||||
static private final Logger LOGGER = Logger.getLogger(ImageAnalyzerModule.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ImageAnalyzerModule.class.getName());
|
||||||
|
|
||||||
static final String MODULE_NAME = ImageAnalyzerModule.class.getSimpleName();
|
static final String MODULE_NAME = ImageAnalyzerModule.class.getSimpleName();
|
||||||
|
|
||||||
static private final Set<String> videoExtensions
|
private static final Set<String> videoExtensions
|
||||||
= Sets.newHashSet("aaf", "3gp", "asf", "avi", "m1v", "m2v", "m4v", "mp4",
|
= Sets.newHashSet("aaf", "3gp", "asf", "avi", "m1v", "m2v", "m4v", "mp4",
|
||||||
"mov", "mpeg", "mpg", "mpe", "mp4", "rm", "wmv", "mpv",
|
"mov", "mpeg", "mpg", "mpe", "mp4", "rm", "wmv", "mpv",
|
||||||
"flv", "swf");
|
"flv", "swf");
|
||||||
|
|
||||||
static private final Set<String> imageExtensions = Sets.newHashSet(ImageIO.getReaderFileSuffixes());
|
private static final Set<String> imageExtensions = Sets.newHashSet(ImageIO.getReaderFileSuffixes());
|
||||||
|
|
||||||
static private final Set<String> supportedExtensions = Sets.union(imageExtensions, videoExtensions);
|
private static final Set<String> supportedExtensions = Sets.union(imageExtensions, videoExtensions);
|
||||||
|
|
||||||
static private final Set<String> imageMimes = Sets.newHashSet("image/jpeg", "image/bmp", "image/gif", "image/png");
|
/** mime types of images we can display */
|
||||||
|
private static final Set<String> imageMimes = Sets.newHashSet("image/jpeg", "image/bmp", "image/gif", "image/png");
|
||||||
static private final Set<String> videoMimes = Sets.newHashSet("video/mp4", "video/x-flv", "video/x-javafx");
|
/** mime types of videos we can display */
|
||||||
|
private static final Set<String> videoMimes = Sets.newHashSet("video/mp4", "video/x-flv", "video/x-javafx");
|
||||||
static private final Set<String> supportedMimes = Sets.union(imageMimes, videoMimes);
|
/** mime types of files we can display */
|
||||||
|
private static final Set<String> supportedMimes = Sets.union(imageMimes, videoMimes);
|
||||||
|
|
||||||
public static Set<String> getSupportedMimes() {
|
public static Set<String> getSupportedMimes() {
|
||||||
return Collections.unmodifiableSet(supportedMimes);
|
return Collections.unmodifiableSet(supportedMimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** provides static utilities, can not be instantiated */
|
||||||
private ImageAnalyzerModule() {
|
private ImageAnalyzerModule() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** is listening enabled for the given case
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
*
|
||||||
|
* @return true if listening is enabled for the given case, false otherwise
|
||||||
|
*/
|
||||||
static boolean isEnabledforCase(Case c) {
|
static boolean isEnabledforCase(Case c) {
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
String enabledforCaseProp = new PerCaseProperties(c).getConfigSetting(ImageAnalyzerModule.MODULE_NAME, PerCaseProperties.ENABLED);
|
String enabledforCaseProp = new PerCaseProperties(c).getConfigSetting(ImageAnalyzerModule.MODULE_NAME, PerCaseProperties.ENABLED);
|
||||||
@ -81,6 +83,13 @@ public class ImageAnalyzerModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** is the drawable db out of date for the given case
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
*
|
||||||
|
* @return true if the drawable db is out of date for the given case, false
|
||||||
|
* otherwise
|
||||||
|
*/
|
||||||
public static boolean isCaseStale(Case c) {
|
public static boolean isCaseStale(Case c) {
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
String stale = new PerCaseProperties(c).getConfigSetting(ImageAnalyzerModule.MODULE_NAME, PerCaseProperties.STALE);
|
String stale = new PerCaseProperties(c).getConfigSetting(ImageAnalyzerModule.MODULE_NAME, PerCaseProperties.STALE);
|
||||||
@ -94,10 +103,20 @@ public class ImageAnalyzerModule {
|
|||||||
return supportedExtensions;
|
return supportedExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** is the given file suported by image analyzer: ie, does it have a
|
||||||
|
* supported mime type. if no mime type is found, does it have a supported
|
||||||
|
* extension or a jpeg header.
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
*
|
||||||
|
* @return true if this file is supported or false if not
|
||||||
|
*/
|
||||||
public static Boolean isSupported(AbstractFile file) {
|
public static Boolean isSupported(AbstractFile file) {
|
||||||
//if there were no file type attributes, or we failed to read it, fall back on extension and jpeg header
|
//if there were no file type attributes, or we failed to read it, fall back on extension and jpeg header
|
||||||
return Optional.ofNullable(hasSupportedMimeType(file)).orElseGet(
|
return Optional.ofNullable(hasSupportedMimeType(file)).orElseGet(() -> {
|
||||||
() -> supportedExtensions.contains(getFileExtension(file)) || ImageUtils.isJpegFileHeader(file));
|
return supportedExtensions.contains(getFileExtension(file))
|
||||||
|
|| ImageUtils.isJpegFileHeader(file);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,7 +141,8 @@ public class ImageAnalyzerModule {
|
|||||||
|
|
||||||
/** @param file
|
/** @param file
|
||||||
*
|
*
|
||||||
* @return
|
* @return true if the given file has a supported video mime type or
|
||||||
|
* extension, else false
|
||||||
*/
|
*/
|
||||||
public static boolean isVideoFile(AbstractFile file) {
|
public static boolean isVideoFile(AbstractFile file) {
|
||||||
try {
|
try {
|
||||||
@ -153,40 +173,4 @@ public class ImageAnalyzerModule {
|
|||||||
static public boolean isSupportedAndNotKnown(AbstractFile abstractFile) {
|
static public boolean isSupportedAndNotKnown(AbstractFile abstractFile) {
|
||||||
return (abstractFile.getKnown() != TskData.FileKnown.KNOWN) && ImageAnalyzerModule.isSupported(abstractFile);
|
return (abstractFile.getKnown() != TskData.FileKnown.KNOWN) && ImageAnalyzerModule.isSupported(abstractFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: this doesn ot really belong here, move it to ImageAnalyzerController? Module?
|
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.UI)
|
|
||||||
public static void closeTopComponent() {
|
|
||||||
final TopComponent etc = WindowManager.getDefault().findTopComponent("ImageAnalyzerTopComponent");
|
|
||||||
if (etc != null) {
|
|
||||||
try {
|
|
||||||
etc.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.log(Level.SEVERE, "failed to close ImageAnalyzerTopComponent", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.UI)
|
|
||||||
public static void openTopComponent() {
|
|
||||||
//TODO:eventually move to this model, throwing away everything and rebuilding controller groupmanager etc for each case.
|
|
||||||
// synchronized (OpenTimelineAction.class) {
|
|
||||||
// if (timeLineController == null) {
|
|
||||||
// timeLineController = new TimeLineController();
|
|
||||||
// LOGGER.log(Level.WARNING, "Failed to get TimeLineController from lookup. Instantiating one directly.S");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// timeLineController.openTimeLine();
|
|
||||||
final ImageAnalyzerTopComponent tc= (ImageAnalyzerTopComponent) WindowManager.getDefault().findTopComponent("ImageAnalyzerTopComponent");
|
|
||||||
if (tc != null) {
|
|
||||||
WindowManager.getDefault().isTopComponentFloating(tc);
|
|
||||||
Mode mode = WindowManager.getDefault().findMode("timeline");
|
|
||||||
if (mode != null) {
|
|
||||||
mode.dockInto(tc);
|
|
||||||
|
|
||||||
}
|
|
||||||
tc.open();
|
|
||||||
tc.requestActive();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.imageanalyzer;
|
package org.sleuthkit.autopsy.imageanalyzer;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.embed.swing.JFXPanel;
|
import javafx.embed.swing.JFXPanel;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
@ -30,7 +31,10 @@ import org.openide.explorer.ExplorerManager;
|
|||||||
import org.openide.explorer.ExplorerUtils;
|
import org.openide.explorer.ExplorerUtils;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
import org.openide.util.NbBundle.Messages;
|
import org.openide.util.NbBundle.Messages;
|
||||||
|
import org.openide.windows.Mode;
|
||||||
import org.openide.windows.TopComponent;
|
import org.openide.windows.TopComponent;
|
||||||
|
import org.openide.windows.WindowManager;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.imageanalyzer.gui.GroupPane;
|
import org.sleuthkit.autopsy.imageanalyzer.gui.GroupPane;
|
||||||
import org.sleuthkit.autopsy.imageanalyzer.gui.MetaDataPane;
|
import org.sleuthkit.autopsy.imageanalyzer.gui.MetaDataPane;
|
||||||
import org.sleuthkit.autopsy.imageanalyzer.gui.StatusBar;
|
import org.sleuthkit.autopsy.imageanalyzer.gui.StatusBar;
|
||||||
@ -57,6 +61,40 @@ import org.sleuthkit.autopsy.imageanalyzer.gui.navpanel.NavPanel;
|
|||||||
public final class ImageAnalyzerTopComponent extends TopComponent implements ExplorerManager.Provider, Lookup.Provider {
|
public final class ImageAnalyzerTopComponent extends TopComponent implements ExplorerManager.Provider, Lookup.Provider {
|
||||||
|
|
||||||
public final static String PREFERRED_ID = "ImageAnalyzerTopComponent";
|
public final static String PREFERRED_ID = "ImageAnalyzerTopComponent";
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(ImageAnalyzerTopComponent.class.getName());
|
||||||
|
|
||||||
|
public static void openTopComponent() {
|
||||||
|
//TODO:eventually move to this model, throwing away everything and rebuilding controller groupmanager etc for each case.
|
||||||
|
// synchronized (OpenTimelineAction.class) {
|
||||||
|
// if (timeLineController == null) {
|
||||||
|
// timeLineController = new TimeLineController();
|
||||||
|
// LOGGER.log(Level.WARNING, "Failed to get TimeLineController from lookup. Instantiating one directly.S");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// timeLineController.openTimeLine();
|
||||||
|
final ImageAnalyzerTopComponent tc = (ImageAnalyzerTopComponent) WindowManager.getDefault().findTopComponent("ImageAnalyzerTopComponent");
|
||||||
|
if (tc != null) {
|
||||||
|
WindowManager.getDefault().isTopComponentFloating(tc);
|
||||||
|
Mode mode = WindowManager.getDefault().findMode("timeline");
|
||||||
|
if (mode != null) {
|
||||||
|
mode.dockInto(tc);
|
||||||
|
}
|
||||||
|
tc.open();
|
||||||
|
tc.requestActive();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: this doesn ot really belong here, move it to ImageAnalyzerController? Module?
|
||||||
|
public static void closeTopComponent() {
|
||||||
|
final TopComponent etc = WindowManager.getDefault().findTopComponent("ImageAnalyzerTopComponent");
|
||||||
|
if (etc != null) {
|
||||||
|
try {
|
||||||
|
etc.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "failed to close ImageAnalyzerTopComponent", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final ExplorerManager em = new ExplorerManager();
|
private final ExplorerManager em = new ExplorerManager();
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import org.sleuthkit.autopsy.core.Installer;
|
|||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.imageanalyzer.ImageAnalyzerController;
|
import org.sleuthkit.autopsy.imageanalyzer.ImageAnalyzerController;
|
||||||
import org.sleuthkit.autopsy.imageanalyzer.ImageAnalyzerModule;
|
import org.sleuthkit.autopsy.imageanalyzer.ImageAnalyzerModule;
|
||||||
|
import org.sleuthkit.autopsy.imageanalyzer.ImageAnalyzerTopComponent;
|
||||||
|
|
||||||
@ActionID(category = "Tools",
|
@ActionID(category = "Tools",
|
||||||
id = "org.sleuthkit.autopsy.imageanalyzer.OpenAction")
|
id = "org.sleuthkit.autopsy.imageanalyzer.OpenAction")
|
||||||
@ -93,14 +94,14 @@ public final class OpenAction extends CallableSystemAction {
|
|||||||
ImageAnalyzerController.getDefault().setListeningEnabled(true);
|
ImageAnalyzerController.getDefault().setListeningEnabled(true);
|
||||||
//fall through
|
//fall through
|
||||||
case JOptionPane.NO_OPTION:
|
case JOptionPane.NO_OPTION:
|
||||||
ImageAnalyzerModule.openTopComponent();
|
ImageAnalyzerTopComponent.openTopComponent();
|
||||||
break;
|
break;
|
||||||
case JOptionPane.CANCEL_OPTION:
|
case JOptionPane.CANCEL_OPTION:
|
||||||
break; //do nothing
|
break; //do nothing
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//case is not stale, just open it
|
//case is not stale, just open it
|
||||||
ImageAnalyzerModule.openTopComponent();
|
ImageAnalyzerTopComponent.openTopComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user