From 8a2f329fd2cdd9a5399f0328f168539a98c73882 Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Mon, 17 Dec 2012 17:08:53 -0500 Subject: [PATCH 1/9] Made hash db messages have error or warning in front of them to draw more attention --- .../src/org/sleuthkit/autopsy/hashdatabase/IndexStatus.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/IndexStatus.java b/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/IndexStatus.java index b29fd237e9..cf02a9f326 100644 --- a/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/IndexStatus.java +++ b/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/IndexStatus.java @@ -28,7 +28,7 @@ enum IndexStatus { /** * The index and database both exist, and the index is older. */ - INDEX_OUTDATED("Index is older than database"), + INDEX_OUTDATED("WARNING: Index is older than database"), /** * The index and database both exist, and the index is not older. */ @@ -40,11 +40,11 @@ enum IndexStatus { /** * The database exists but the index does not. */ - NO_INDEX("Index does not exist"), + NO_INDEX("ERROR: Index does not exist"), /** * Neither the index nor the database exists. */ - NONE("No index or database"), + NONE("ERROR: No index or database"), /** * The index is currently being generated */ From 7473024d23992ade172b4093fc8e12f66122eaca Mon Sep 17 00:00:00 2001 From: Tim McIver Date: Tue, 18 Dec 2012 14:06:58 -0500 Subject: [PATCH 2/9] Updated code in method DataContentTopComponent.setupTabs() to remove logic that changed to the tab with the highest priority. Now, the tab selected by the user does not change when nodes are selected. This change is in support of Github issue #99: https://github.com/sleuthkit/autopsy/issues/99 --- .../DataContentTopComponent.java | 37 +++++++------------ .../DataContentViewerString.java | 2 +- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java index 721928e257..49f9bc86f2 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java @@ -52,6 +52,7 @@ public final class DataContentTopComponent extends TopComponent implements DataC private boolean isDefault; // Different DataContentViewers private List viewers = new ArrayList(); + // contains a list of the undocked TCs private static ArrayList newWindowList = new ArrayList(); private static final String PREFERRED_ID = "DataContentTopComponent"; @@ -291,34 +292,22 @@ public final class DataContentTopComponent extends TopComponent implements DataC */ public void setupTabs(Node selectedNode) { + int currTabIndex = dataContentTabbedPane.getSelectedIndex(); int totalTabs = dataContentTabbedPane.getTabCount(); - - int maxPreferred = 0; - int indexOfPreferred = 0; + for (int i = 0; i < totalTabs; ++i) { + UpdateWrapper dcv = viewers.get(i); + dcv.resetComponent(); - if (totalTabs > 0) { // make sure there are tabs to reset - for (int i = 0; i < totalTabs; i++) { - UpdateWrapper dcv = viewers.get(i); - dcv.resetComponent(); - - // disable an unsupported tab (ex: picture viewer) - boolean dcvSupported = dcv.isSupported(selectedNode); - if (! dcvSupported) { - dataContentTabbedPane.setEnabledAt(i, false); - } else { - dataContentTabbedPane.setEnabledAt(i, true); - int currentPreferred = dcv.isPreferred(selectedNode, dcvSupported); - if (currentPreferred > maxPreferred) { - indexOfPreferred = i; - maxPreferred = currentPreferred; - } - - } + // disable an unsupported tab (ex: picture viewer) + boolean dcvSupported = dcv.isSupported(selectedNode); + if (!dcvSupported) { + dataContentTabbedPane.setEnabledAt(i, false); + } else { + dataContentTabbedPane.setEnabledAt(i, true); } - // set the display of the tab - dataContentTabbedPane.setSelectedIndex(indexOfPreferred); - viewers.get(indexOfPreferred).setNode(selectedNode); } + + viewers.get(currTabIndex).setNode(selectedNode); } /** diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerString.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerString.java index dcfd151efa..aea4116a0d 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerString.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerString.java @@ -482,7 +482,7 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC @Override public int isPreferred(Node node, boolean isSupported) { if(node != null && isSupported){ - return 2; + return 1; } else { return 0; } From a2664b3348626d7aa75c5a8cfdc4f865f2bd319e Mon Sep 17 00:00:00 2001 From: Tim McIver Date: Tue, 18 Dec 2012 14:18:04 -0500 Subject: [PATCH 3/9] Deleted DataContentViewerPicture.[java|form] that is no longer needed. --- .../DataContentViewerPicture.form | 45 ---- .../DataContentViewerPicture.java | 193 ------------------ 2 files changed, 238 deletions(-) delete mode 100644 Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerPicture.form delete mode 100644 Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerPicture.java diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerPicture.form b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerPicture.form deleted file mode 100644 index 43f9a88aea..0000000000 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerPicture.form +++ /dev/null @@ -1,45 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerPicture.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerPicture.java deleted file mode 100644 index 5d1491b6fc..0000000000 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerPicture.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2011 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.corecomponents; - -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Image; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.logging.Level; -import org.sleuthkit.autopsy.coreutils.Logger; -import javax.imageio.ImageIO; -import javax.swing.JPanel; -import org.openide.nodes.Node; -import org.openide.util.lookup.ServiceProvider; -import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer; -import org.sleuthkit.datamodel.Content; -import org.sleuthkit.datamodel.File; -import org.sleuthkit.datamodel.FsContent; -import org.sleuthkit.datamodel.TskException; - -/** - * File content viewer capable of displaying some image formats. - */ -//@ServiceProvider(service = DataContentViewer.class) -public class DataContentViewerPicture extends javax.swing.JPanel implements DataContentViewer { - - // for error handling - private JPanel caller; - private String className = this.getClass().toString(); - - /** Creates new form DataContentViewerPicture */ - public DataContentViewerPicture() { - initComponents(); - this.resetComponent(); - } - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - picViewerScrollPanel = new javax.swing.JScrollPane(); - picLabel = new javax.swing.JLabel(); - - picLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - picLabel.setText(org.openide.util.NbBundle.getMessage(DataContentViewerPicture.class, "DataContentViewerPicture.picLabel.text")); // NOI18N - picLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - picViewerScrollPanel.setViewportView(picLabel); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(picViewerScrollPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(picViewerScrollPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE) - ); - }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JLabel picLabel; - private javax.swing.JScrollPane picViewerScrollPanel; - // End of variables declaration//GEN-END:variables - - @Override - public void setNode(Node selectedNode) { - // change the cursor to "waiting cursor" for this operation - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - try { - if (selectedNode != null) { - try { - // read the byte of the image file - - Content content = selectedNode.getLookup().lookup(Content.class); - byte[] dataSource = new byte[(int) content.getSize()]; - int bytesRead = content.read(dataSource, 0, content.getSize()); - - // create the input stream for the content - if (bytesRead > 0) { - InputStream is = new ByteArrayInputStream(dataSource); - - Image image = ImageIO.read(is); // create the image - - if (image!= null) - this.picLabel.setIcon(new javax.swing.ImageIcon(image)); // show the file - } - - - } catch (TskException ex) { - // TODO: maybe make errors bubble - Logger.getLogger(this.className).log(Level.WARNING, "Error while trying to display the picture content.", ex); - } catch (Exception ex) { - Logger.getLogger(this.className).log(Level.WARNING, "Error while trying to display the picture content.", ex); - } - } - } finally { - this.setCursor(null); - } - } - - @Override - public String getTitle() { - return "Picture View"; - } - - @Override - public String getToolTip() { - return "Displays supported image files."; - } - - @Override - public DataContentViewer getInstance() { - return new DataContentViewerPicture(); - } - - @Override - public void resetComponent() { - this.picLabel.setText(""); - //this.picLabel.setIcon(null); - } - - @Override - public boolean isSupported(Node node) { - if (node != null) { - // Note: only supports JPG, GIF, and PNG for now - /*return node.getDisplayName().toLowerCase().endsWith(".jpg") - || node.getDisplayName().toLowerCase().endsWith(".jpeg") - || node.getDisplayName().toLowerCase().endsWith(".jpe") - || node.getDisplayName().toLowerCase().endsWith(".jfif") - || node.getDisplayName().toLowerCase().endsWith(".gif") - || node.getDisplayName().toLowerCase().endsWith(".bmp") - || //node.getDisplayName().toLowerCase().endsWith(".tif") || - //node.getDisplayName().toLowerCase().endsWith(".tiff") || - //node.getDisplayName().toLowerCase().endsWith(".tga") || - node.getDisplayName().toLowerCase().endsWith(".png");*/ - File file = node.getLookup().lookup(File.class); - - if (file != null) { - return file.getSize() > 0 - && (file.getName().toLowerCase().endsWith(".jpg") - || file.getName().toLowerCase().endsWith(".jpeg") - || file.getName().toLowerCase().endsWith(".jpe") - || file.getName().toLowerCase().endsWith(".jfif") - || file.getName().toLowerCase().endsWith(".gif") - || file.getName().toLowerCase().endsWith(".bmp") - || //node.getName().toLowerCase().endsWith(".tif") || - //node.getName().toLowerCase().endsWith(".tiff") || - //node.getName().toLowerCase().endsWith(".tga") || - file.getName().toLowerCase().endsWith(".png")); - } else { - return false; - } - } else { - return false; - } - } - - @Override - public int isPreferred(Node node, boolean isSupported) { - if(isSupported) { - return 1; - } else { - return 0; - } - } - - @Override - public Component getComponent() { - return this; - } -} From baaf8cbec9bea1fc2d062ee868e7621ca970cc77 Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Tue, 18 Dec 2012 16:45:16 -0500 Subject: [PATCH 4/9] Updated log message to record each file and added last priority status for non-file files --- .../autopsy/ingest/IngestManager.java | 5 ++-- .../autopsy/ingest/IngestScheduler.java | 27 +++++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java index df0aec6e8d..2ce44b0003 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java @@ -814,8 +814,7 @@ public class IngestManager { final AbstractFile fileToProcess = fileTask.file; - //logger.log(Level.INFO, "NEXT FILE: " + fileToProcess.getName()); - + logger.log(Level.INFO, "IngestManager: Processing: {0}", fileToProcess.getName()); progress.progress(fileToProcess.getName(), processedFiles); for (IngestModuleAbstractFile module : fileTask.scheduledTask.modules) { @@ -857,7 +856,7 @@ public class IngestManager { //--totalEnqueuedFiles; } //end of this AbstractFile - logger.log(Level.INFO, "Done background processing"); + logger.log(Level.INFO, "IngestManager: Finished processing files"); return null; } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java index 482fdd9762..bc506eef97 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java @@ -663,21 +663,31 @@ class IngestScheduler { enum Priority { - LOW, MEDIUM, HIGH + LAST, LOW, MEDIUM, HIGH }; + static final List LAST_PRI_PATHS = new ArrayList(); static final List LOW_PRI_PATHS = new ArrayList(); static final List MEDIUM_PRI_PATHS = new ArrayList(); static final List HIGH_PRI_PATHS = new ArrayList(); + /* prioritize root directory folders based on the assumption that we are + * looking for user content. Other types of investigations may want different + * priorities. */ static { + // these files have no structure, so they go last + LAST_PRI_PATHS.add(Pattern.compile("^\\$Unalloc", Pattern.CASE_INSENSITIVE)); + LAST_PRI_PATHS.add(Pattern.compile("^pagefile", Pattern.CASE_INSENSITIVE)); + LAST_PRI_PATHS.add(Pattern.compile("^hiberfil", Pattern.CASE_INSENSITIVE)); + + // orphan files are often corrupt and windows does not typically have + // user content, so put them towards the bottom + LOW_PRI_PATHS.add(Pattern.compile("^\\$OrphanFiles", Pattern.CASE_INSENSITIVE)); LOW_PRI_PATHS.add(Pattern.compile("^Windows", Pattern.CASE_INSENSITIVE)); + // all other files go into the medium category too MEDIUM_PRI_PATHS.add(Pattern.compile("^Program Files", Pattern.CASE_INSENSITIVE)); - MEDIUM_PRI_PATHS.add(Pattern.compile("^\\$OrphanFiles", Pattern.CASE_INSENSITIVE)); - MEDIUM_PRI_PATHS.add(Pattern.compile("^\\$Unalloc", Pattern.CASE_INSENSITIVE)); - MEDIUM_PRI_PATHS.add(Pattern.compile("^pagefile", Pattern.CASE_INSENSITIVE)); - MEDIUM_PRI_PATHS.add(Pattern.compile("^hiberfil", Pattern.CASE_INSENSITIVE)); + // user content is top priority HIGH_PRI_PATHS.add(Pattern.compile("^Users", Pattern.CASE_INSENSITIVE)); HIGH_PRI_PATHS.add(Pattern.compile("^Documents and Settings", Pattern.CASE_INSENSITIVE)); HIGH_PRI_PATHS.add(Pattern.compile("^home", Pattern.CASE_INSENSITIVE)); @@ -715,6 +725,13 @@ class IngestScheduler { return AbstractFilePriotity.Priority.LOW; } } + + for (Pattern p : LAST_PRI_PATHS) { + Matcher m = p.matcher(path); + if (m.find()) { + return AbstractFilePriotity.Priority.LAST; + } + } //default is medium return AbstractFilePriotity.Priority.MEDIUM; From f813771727d01178503c278613a0c7c77c9e421f Mon Sep 17 00:00:00 2001 From: adam-m Date: Tue, 18 Dec 2012 16:54:26 -0500 Subject: [PATCH 5/9] update rcp version --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 29167c3773..f9fe72f1a5 100644 --- a/README.txt +++ b/README.txt @@ -47,7 +47,7 @@ JRE (Java Runtime Environment) 1.6, 32 bit - Web page: http://www.oracle.com/technetwork/java/index.html - License: http://www.oracle.com/technetwork/java/javase/terms/license/index.html -Netbeans 7.0.1 RCP platform and .jar files bundled with the platform +Netbeans 7.2.1 RCP platform and .jar files bundled with the platform - Web page: http://netbeans.org/features/platform/ - License: http://services.netbeans.org/downloads/licence/nb-7.0-final-2011-04-20-license.txt From 7da7863727728d075f6ca18d5ca2ea7b9f86dd8b Mon Sep 17 00:00:00 2001 From: adam-m Date: Tue, 18 Dec 2012 17:04:28 -0500 Subject: [PATCH 6/9] do not give medium priority if non-fs file type --- Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java index bc506eef97..d80ee7d480 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestScheduler.java @@ -695,10 +695,10 @@ class IngestScheduler { } static AbstractFilePriotity.Priority getPriority(final AbstractFile abstractFile) { - if (!abstractFile.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.FS)) { + //if (!abstractFile.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.FS)) { //non-fs files, such as representing unalloc space - return AbstractFilePriotity.Priority.MEDIUM; - } + //return AbstractFilePriotity.Priority.MEDIUM; + //} final String path = abstractFile.getName(); if (path == null) { From adae62df4acccbb84b9500417e7e01b735bd4ce3 Mon Sep 17 00:00:00 2001 From: Tim McIver Date: Wed, 19 Dec 2012 14:58:39 -0500 Subject: [PATCH 7/9] Updated DataContentViewerMedia to use SwingWorker to do updates to progress slider and duration label. Also added code to clear the duration label in reset method so that duration of previous video does not remain when a new video is selected. --- .../DataContentViewerMedia.java | 166 +++++++++++------- 1 file changed, 100 insertions(+), 66 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerMedia.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerMedia.java index ea0a2c03a0..2857368f12 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerMedia.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerMedia.java @@ -25,6 +25,7 @@ import java.util.concurrent.CancellationException; import java.util.logging.Level; import org.sleuthkit.autopsy.coreutils.Logger; import javax.swing.BoxLayout; +import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -59,6 +60,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo private long durationMillis = 0; private boolean autoTracking = false; // true if the slider is moving automatically private final Object playbinLock = new Object(); // lock for synchronization of playbin2 player + private VideoProgressWorker videoProgressWorker; /** * Creates new form DataContentViewerVideo @@ -186,6 +188,12 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo if (selectedNode == null) { return; } + + // get rid of any existing videoProgressWorker thread + if (videoProgressWorker != null) { + videoProgressWorker.cancel(true); + videoProgressWorker = null; + } File file = selectedNode.getLookup().lookup(File.class); if (file == null) { @@ -303,15 +311,19 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo } private void reset() { + // reset the progress label text on the event dispatch thread + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + progressLabel.setText(" "); + } + }); synchronized (playbinLock) { if (playbin2 != null) { if (playbin2.isPlaying()) { playbin2.stop(); } playbin2.setState(State.NULL); -// try { -// Thread.sleep(20); // gstreamer needs to catch up -// } catch (InterruptedException ex) { } if (playbin2.getState().equals(State.NULL)) { playbin2.dispose(); } @@ -397,8 +409,6 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo this.jFile = jFile; } - ; - @Override protected Object doInBackground() throws Exception { success = false; @@ -444,7 +454,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo progressLabel.setText("Error buffering file"); return; } - ClockTime dur = null; + ClockTime dur = null; synchronized (playbinLock) { playbin2.play(); // must play, then pause and get state to get duration. playbin2.pause(); @@ -454,73 +464,97 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo duration = dur.toString(); durationMillis = dur.toMillis(); - progressSlider.setMaximum((int) durationMillis); - progressSlider.setMinimum(0); - final String finalDuration; - if (duration.length() == 8 && duration.substring(0, 3).equals("00:")) { - finalDuration = duration.substring(3); - progressLabel.setText("00:00/" + duration); - } else { - finalDuration = duration; - progressLabel.setText("00:00:00/" + duration); - } - synchronized (playbinLock) { - playbin2.play(); - } - pauseButton.setText("||"); - new Thread(new Runnable() { - private boolean isPlayBinReady() { - synchronized (playbinLock) { - return playbin2 != null && !playbin2.getState().equals(State.NULL); - } - } - + SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - long positionMillis = 0; - while (positionMillis < durationMillis - && isPlayBinReady() ) { - ClockTime pos = null; - synchronized (playbinLock) { - pos = playbin2.queryPosition(); - } - position = pos.toString(); - positionMillis = pos.toMillis(); - - if (position.length() == 8) { - position = position.substring(3); - } - progressLabel.setText(position + "/" + finalDuration); - autoTracking = true; - progressSlider.setValue((int) positionMillis); - autoTracking = false; - try { - Thread.sleep(20); - } catch (InterruptedException ex) { - } - } - if (finalDuration.length() == 5) { - progressLabel.setText("00:00/" + finalDuration); + progressSlider.setMaximum((int) durationMillis); + progressSlider.setMinimum(0); + final String finalDuration; + if (duration.length() == 8 && duration.substring(0, 3).equals("00:")) { + finalDuration = duration.substring(3); + progressLabel.setText("00:00/" + duration); } else { - progressLabel.setText("00:00:00/" + finalDuration); + finalDuration = duration; + progressLabel.setText("00:00:00/" + duration); } - // If it reached the end - if (progressSlider.getValue() == progressSlider.getMaximum()) { - restartVideo(); - } - } - - public void restartVideo() { synchronized (playbinLock) { - if (playbin2 != null) { - playbin2.stop(); - playbin2.setState(State.READY); // ready to be played again - } + playbin2.play(); } - pauseButton.setText("►"); - progressSlider.setValue(0); + pauseButton.setText("||"); + videoProgressWorker = new VideoProgressWorker(); + videoProgressWorker.execute(); } - }).start(); + }); + } + } + + private class VideoProgressWorker extends SwingWorker { + + private boolean isPlayBinReady() { + synchronized (playbinLock) { + return playbin2 != null && !playbin2.getState().equals(State.NULL); + } + } + + public void restartVideo() { + synchronized (playbinLock) { + if (playbin2 != null) { + playbin2.stop(); + playbin2.setState(State.READY); // ready to be played again + } + } + pauseButton.setText("►"); + progressSlider.setValue(0); + } + + @Override + protected Object doInBackground() throws Exception { + long positionMillis = 0; + String finalDuration = ""; + while (positionMillis < durationMillis + && isPlayBinReady() && !isCancelled()) { + ClockTime pos = null; + synchronized (playbinLock) { + pos = playbin2.queryPosition(); + } + String position = pos.toString(); + positionMillis = pos.toMillis(); + + if (position.length() == 8) { + position = position.substring(3); + } + + String duration = playbin2.queryDuration().toString(); + if (duration.length() == 8 && duration.substring(0, 3).equals("00:")) { + finalDuration = duration.substring(3); + progressLabel.setText("00:00/" + duration); + } else { + finalDuration = duration; + progressLabel.setText("00:00:00/" + duration); + } + + progressLabel.setText(position + "/" + finalDuration); + autoTracking = true; + progressSlider.setValue((int) positionMillis); + autoTracking = false; + try { + Thread.sleep(20); + } catch (InterruptedException ex) { + throw ex; + } + } + + if (finalDuration.length() == 5) { + progressLabel.setText("00:00/" + finalDuration); + } else { + progressLabel.setText("00:00:00/" + finalDuration); + } + // If it reached the end + if (progressSlider.getValue() == progressSlider.getMaximum()) { + restartVideo(); + } + + return null; } } } From 6b25b4c34bf2790c0acba76bdda07fdb6137c999 Mon Sep 17 00:00:00 2001 From: adam-m Date: Wed, 19 Dec 2012 17:57:26 -0500 Subject: [PATCH 8/9] update RCP version for consistency (likely obsolete here) --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index 55c5a6511d..d4cefd11c4 100644 --- a/build.xml +++ b/build.xml @@ -7,7 +7,7 @@ - + From 6ee69fc881e92973e62b7bd44d18ce8c60bda040 Mon Sep 17 00:00:00 2001 From: adam-m Date: Thu, 20 Dec 2012 11:14:12 -0500 Subject: [PATCH 9/9] RA: fix chrome null ptr exception when extracting bookmarks --- .../autopsy/recentactivity/Chrome.java | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java index 153d2989b0..3151cc22db 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java @@ -179,7 +179,7 @@ public class Chrome extends Extract implements IngestModuleImage { break; } try { - final JsonParser parser = new JsonParser(); + final JsonParser parser = new JsonParser(); JsonElement jsonElement = parser.parse(new FileReader(temps)); JsonObject jElement = jsonElement.getAsJsonObject(); JsonObject jRoot = jElement.get("roots").getAsJsonObject(); @@ -188,9 +188,33 @@ public class Chrome extends Extract implements IngestModuleImage { for (JsonElement result : jBookmarkArray) { try { JsonObject address = result.getAsJsonObject(); - String url = address.get("url").getAsString(); - String name = address.get("name").getAsString(); - Long date = address.get("date_added").getAsLong(); + if (address == null) { + continue; + } + JsonElement urlEl = address.get("url"); + String url = null; + if (urlEl != null) { + url = urlEl.getAsString(); + } + else { + url = ""; + } + String name = null; + JsonElement nameEl = address.get("name"); + if (nameEl != null) { + name = nameEl.getAsString(); + } + else { + name = ""; + } + Long date = null; + JsonElement dateEl = address.get("date_added"); + if (dateEl != null) { + date = dateEl.getAsLong(); + } + else { + date = Long.valueOf(0); + } String domain = Util.extractDomain(url); BlackboardArtifact bbart = bookmarkFiles.get(j).newArtifact(ARTIFACT_TYPE.TSK_WEB_BOOKMARK); Collection bbattributes = new ArrayList();