try{
PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getDefaultPluginInterface();
ShareManager sm = pi.getShareManager();
Tracker tracker = pi.getTracker();
ShareResource[] shares = sm.getShares();
TOTorrent torrent = dm.getTorrent();
byte[] target_hash = torrent.getHash();
for ( ShareResource share: shares ){
int type = share.getType();
byte[] hash;
if ( type == ShareResource.ST_DIR ){
hash = ((ShareResourceDir)share).getItem().getTorrent().getHash();
}else if ( type == ShareResource.ST_FILE ){
hash = ((ShareResourceFile)share).getItem().getTorrent().getHash();
}else{
hash = null;
}
if ( hash != null ){
if ( Arrays.equals( target_hash, hash )){
try{
dm.stopIt( DownloadManager.STATE_STOPPED, false, false );
}catch( Throwable e ){
}
try{
TrackerTorrent tracker_torrent = tracker.getTorrent( PluginCoreUtils.wrap( torrent ));
if ( tracker_torrent != null ){
tracker_torrent.stop();
}