mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-20 11:26:53 +00:00
Merge pull request #3157 from raman-bt/accounts_relationships
Milestone 1 UI/CommuncationsManager integration
This commit is contained in:
commit
01e218d248
@ -18,26 +18,35 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.communications;
|
package org.sleuthkit.autopsy.communications;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import org.openide.nodes.AbstractNode;
|
import org.openide.nodes.AbstractNode;
|
||||||
import org.openide.nodes.Children;
|
import org.openide.nodes.Children;
|
||||||
import org.openide.nodes.Sheet;
|
import org.openide.nodes.Sheet;
|
||||||
|
import org.openide.util.Exceptions;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.util.lookup.Lookups;
|
import org.openide.util.lookup.Lookups;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
||||||
import org.sleuthkit.datamodel.Account;
|
import org.sleuthkit.datamodel.Account;
|
||||||
|
import org.sleuthkit.datamodel.AccountDeviceInstance;
|
||||||
|
import org.sleuthkit.datamodel.CommunicationsFilter;
|
||||||
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node to represent an Account in the AccountsBrowser
|
* Node to represent an Account in the AccountsBrowser
|
||||||
*/
|
*/
|
||||||
class AccountNode extends AbstractNode {
|
class AccountDeviceInstanceNode extends AbstractNode {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(AbstractNode.class.getName());
|
||||||
|
|
||||||
private final Account account;
|
private final AccountDeviceInstance accountDeviceInstance;
|
||||||
|
|
||||||
AccountNode(Account account) {
|
AccountDeviceInstanceNode(AccountDeviceInstance accountDeviceInstance) {
|
||||||
super(Children.LEAF, Lookups.fixed(account));
|
super(Children.LEAF, Lookups.fixed(accountDeviceInstance));
|
||||||
this.account = account;
|
this.accountDeviceInstance = accountDeviceInstance;
|
||||||
setName(account.getAccountUniqueID());
|
setName(accountDeviceInstance.getAccount().getAccountUniqueID());
|
||||||
setIconBaseWithExtension("org/sleuthkit/autopsy/communications/images/" + getIconFileName(account.getAccountType()));
|
setIconBaseWithExtension("org/sleuthkit/autopsy/communications/images/" + getIconFileName(accountDeviceInstance.getAccount().getAccountType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,25 +56,25 @@ class AccountNode extends AbstractNode {
|
|||||||
* @return The file name of the icon for the given Account Type.
|
* @return The file name of the icon for the given Account Type.
|
||||||
*/
|
*/
|
||||||
final String getIconFileName(Account.Type type) {
|
final String getIconFileName(Account.Type type) {
|
||||||
if (type == Account.Type.CREDIT_CARD) {
|
if (type.equals(Account.Type.CREDIT_CARD)) {
|
||||||
return "credit-card.png";
|
return "credit-card.png";
|
||||||
} else if (type == Account.Type.DEVICE) {
|
} else if (type.equals(Account.Type.DEVICE)) {
|
||||||
return "image.png";
|
return "image.png";
|
||||||
} else if (type == Account.Type.EMAIL) {
|
} else if (type.equals(Account.Type.EMAIL)) {
|
||||||
return "email.png";
|
return "email.png";
|
||||||
} else if (type == Account.Type.FACEBOOK) {
|
} else if (type.equals(Account.Type.FACEBOOK)) {
|
||||||
return "facebook.png";
|
return "facebook.png";
|
||||||
} else if (type == Account.Type.INSTAGRAM) {
|
} else if (type.equals(Account.Type.INSTAGRAM)) {
|
||||||
return "instagram.png";
|
return "instagram.png";
|
||||||
} else if (type == Account.Type.MESSAGING_APP) {
|
} else if (type.equals(Account.Type.MESSAGING_APP)) {
|
||||||
return "messaging.png";
|
return "messaging.png";
|
||||||
} else if (type == Account.Type.PHONE) {
|
} else if (type.equals(Account.Type.PHONE)) {
|
||||||
return "phone.png";
|
return "phone.png";
|
||||||
} else if (type == Account.Type.TWITTER) {
|
} else if (type.equals(Account.Type.TWITTER)) {
|
||||||
return "twitter.png";
|
return "twitter.png";
|
||||||
} else if (type == Account.Type.WEBSITE) {
|
} else if (type.equals(Account.Type.WEBSITE)) {
|
||||||
return "web-file.png";
|
return "web-file.png";
|
||||||
} else if (type == Account.Type.WHATSAPP) {
|
} else if (type.equals(Account.Type.WHATSAPP)) {
|
||||||
return "WhatsApp.png";
|
return "WhatsApp.png";
|
||||||
} else {
|
} else {
|
||||||
//there could be a default icon instead...
|
//there could be a default icon instead...
|
||||||
@ -88,20 +97,32 @@ class AccountNode extends AbstractNode {
|
|||||||
s.put(properties);
|
s.put(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RAMAN TBD: need to figure out how to get the right filters here
|
||||||
|
// We talked about either creating a wrapper class around AccountDeviceInstance to push the selected filters
|
||||||
|
// Or some kind of static access to pull the selected filters
|
||||||
|
long msgCount = 0;
|
||||||
|
try {
|
||||||
|
CommunicationsFilter filter = null;
|
||||||
|
msgCount = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager().getRelationshipsCount(filter, accountDeviceInstance);
|
||||||
|
}
|
||||||
|
catch (TskCoreException ex) {
|
||||||
|
LOGGER.log(Level.WARNING, "Failed to get message count for account", ex); //NON-NLS
|
||||||
|
}
|
||||||
|
|
||||||
properties.put(new NodeProperty<>("type",
|
properties.put(new NodeProperty<>("type",
|
||||||
Bundle.AccountNode_accountType(),
|
Bundle.AccountNode_accountType(),
|
||||||
"type",
|
"type",
|
||||||
account.getAccountType().getDisplayName())); // NON-NLS
|
accountDeviceInstance.getAccount().getAccountType().getDisplayName())); // NON-NLS
|
||||||
|
|
||||||
properties.put(new NodeProperty<>("count",
|
properties.put(new NodeProperty<>("count",
|
||||||
Bundle.AccountNode_messageCount(),
|
Bundle.AccountNode_messageCount(),
|
||||||
"count",
|
"count",
|
||||||
1)); // NON-NLS //dummy value
|
msgCount)); // NON-NLS
|
||||||
|
|
||||||
//how do I get the device name
|
properties.put(new NodeProperty<>("device",
|
||||||
// properties.put(new NodeProperty<>("device",
|
Bundle.AccountNode_device(),
|
||||||
// Bundle.AccountNode_device(),
|
"device",
|
||||||
// "device",
|
accountDeviceInstance.getDeviceId())); // NON-NLS
|
||||||
// account.)); // NON-NLS
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,15 +22,15 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.openide.nodes.Children;
|
import org.openide.nodes.Children;
|
||||||
import org.openide.nodes.Node;
|
import org.openide.nodes.Node;
|
||||||
import org.sleuthkit.datamodel.Account;
|
import org.sleuthkit.datamodel.AccountDeviceInstance;
|
||||||
|
|
||||||
class AccountsNodeChildren extends Children.Keys<Account> {
|
class AccountDeviceInstancesNodeChildren extends Children.Keys<AccountDeviceInstance> {
|
||||||
|
|
||||||
private final List<Account> accounts;
|
private final List<AccountDeviceInstance> accountDeviceInstances;
|
||||||
|
|
||||||
AccountsNodeChildren(List<Account> accounts) {
|
AccountDeviceInstancesNodeChildren(List<AccountDeviceInstance> accountDeviceInstances) {
|
||||||
super(true);
|
super(true);
|
||||||
this.accounts = accounts;
|
this.accountDeviceInstances = accountDeviceInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +42,7 @@ class AccountsNodeChildren extends Children.Keys<Account> {
|
|||||||
@Override
|
@Override
|
||||||
protected void addNotify() {
|
protected void addNotify() {
|
||||||
super.addNotify();
|
super.addNotify();
|
||||||
setKeys(accounts);
|
setKeys(accountDeviceInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
//These are the methods for ChildFactory. I am going to keep them around but commented until we make a final descision.
|
//These are the methods for ChildFactory. I am going to keep them around but commented until we make a final descision.
|
||||||
@ -54,10 +54,10 @@ class AccountsNodeChildren extends Children.Keys<Account> {
|
|||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
// protected Node createNodeForKey(Account key) {
|
// protected Node createNodeForKey(Account key) {
|
||||||
// return new AccountNode(key);
|
// return new AccountDeviceInstanceNode(key);
|
||||||
// }
|
// }
|
||||||
@Override
|
@Override
|
||||||
protected Node[] createNodes(Account key) {
|
protected Node[] createNodes(AccountDeviceInstance key) {
|
||||||
return new Node[]{new AccountNode(key)};
|
return new Node[]{new AccountDeviceInstanceNode(key)};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,7 +31,7 @@ import org.openide.windows.TopComponent;
|
|||||||
import org.openide.windows.WindowManager;
|
import org.openide.windows.WindowManager;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
|
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
|
||||||
import org.sleuthkit.datamodel.Account;
|
import org.sleuthkit.datamodel.AccountDeviceInstance;
|
||||||
import org.sleuthkit.datamodel.CommunicationsManager;
|
import org.sleuthkit.datamodel.CommunicationsManager;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
|
||||||
@ -162,12 +162,12 @@ public final class CVTTopComponent extends TopComponent implements ExplorerManag
|
|||||||
* ExplorerManager
|
* ExplorerManager
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
List<Account> accounts = new ArrayList<>();
|
List<AccountDeviceInstance> accountDeviceInstances = new ArrayList<>();
|
||||||
|
|
||||||
final CommunicationsManager communicationsManager = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager();
|
final CommunicationsManager communicationsManager = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager();
|
||||||
accounts.addAll(communicationsManager.getAccounts(Account.Type.EMAIL));
|
accountDeviceInstances.addAll(communicationsManager.getAccountDeviceInstancesWithRelationships(null));
|
||||||
accounts.addAll(communicationsManager.getAccounts(Account.Type.DEVICE));
|
|
||||||
|
em.setRootContext(new AbstractNode(new AccountDeviceInstancesNodeChildren(accountDeviceInstances)));
|
||||||
em.setRootContext(new AbstractNode(new AccountsNodeChildren(accounts)));
|
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user