Search in sources :

Example 11 with HashWrapper

use of com.biglybt.core.util.HashWrapper in project BiglyBT by BiglySoftware.

the class SearchSubsUtils method getHashStatus.

public static int getHashStatus(SearchSubsResultBase result) {
    if (result == null) {
        return (HS_NONE);
    }
    byte[] hash = result.getHash();
    if (hash == null || hash.length != 20) {
        return (HS_UNKNOWN);
    }
    long now = SystemTime.getMonotonousTime();
    Object[] entry = (Object[]) result.getUserData(HS_KEY);
    if (entry != null) {
        long time = (Long) entry[0];
        if (now - time < 10 * 1000) {
            return ((Integer) entry[1]);
        }
    }
    synchronized (HS_KEY) {
        if (gm == null) {
            Core core = CoreFactory.getSingleton();
            gm = core.getGlobalManager();
            dm = core.getPluginManager().getDefaultPluginInterface().getDownloadManager();
            hm = (DownloadHistoryManager) gm.getDownloadHistoryManager();
        }
    }
    int hs_result;
    com.biglybt.core.download.DownloadManager dl = gm.getDownloadManager(new HashWrapper(hash));
    if (dl != null) {
        DownloadManagerState downloadState = dl.getDownloadState();
        hs_result = downloadState != null && downloadState.getFlag(DownloadManagerState.FLAG_METADATA_DOWNLOAD) ? HS_FETCHING : HS_LIBRARY;
    } else if (dm.lookupDownloadStub(hash) != null) {
        hs_result = HS_ARCHIVE;
    } else if (hm.getDates(hash) != null) {
        hs_result = HS_HISTORY;
    } else {
        hs_result = HS_NONE;
    }
    result.setUserData(HS_KEY, new Object[] { now + RandomUtils.nextInt(2500), hs_result });
    return (hs_result);
}
Also used : HashWrapper(com.biglybt.core.util.HashWrapper) DownloadManagerState(com.biglybt.core.download.DownloadManagerState) Core(com.biglybt.core.Core)

Example 12 with HashWrapper

use of com.biglybt.core.util.HashWrapper in project BiglyBT by BiglySoftware.

the class SBC_DownloadHistoryView method defaultSelected.

@Override
public void defaultSelected(TableRowCore[] rows, int stateMask) {
    if (rows.length == 1) {
        DownloadHistory dh = (DownloadHistory) rows[0].getDataSource();
        byte[] hash = dh.getTorrentHash();
        DownloadManager dm = CoreFactory.getSingleton().getGlobalManager().getDownloadManager(new HashWrapper(hash));
        if (dm != null) {
            UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_LIBRARY);
            dm.fireGlobalManagerEvent(GlobalManagerEvent.ET_REQUEST_ATTENTION);
        }
    }
}
Also used : DownloadHistory(com.biglybt.core.history.DownloadHistory) HashWrapper(com.biglybt.core.util.HashWrapper) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 13 with HashWrapper

use of com.biglybt.core.util.HashWrapper in project BiglyBT by BiglySoftware.

the class DHTLog method getString.

public static String getString(Map s) {
    if (logging_on) {
        StringBuilder sb = new StringBuilder(128);
        sb.append("{");
        Iterator it = s.keySet().iterator();
        while (it.hasNext()) {
            if (sb.length() > 1) {
                sb.append(",");
            }
            sb.append(getString((HashWrapper) it.next()));
        }
        sb.append("}");
        return (sb.toString());
    } else {
        return ("");
    }
}
Also used : HashWrapper(com.biglybt.core.util.HashWrapper) Iterator(java.util.Iterator)

Example 14 with HashWrapper

use of com.biglybt.core.util.HashWrapper in project BiglyBT by BiglySoftware.

the class DHTDBMapping method getOriginatorValueID.

private HashWrapper getOriginatorValueID(DHTDBValueImpl value) {
    DHTTransportContact originator = value.getOriginator();
    byte[] originator_id = originator.getID();
    return (new HashWrapper(originator_id));
/*
		byte[]	value_bytes 	= value.getValue();

		byte[]	x = new byte[originator_id.length + value_bytes.length];

		System.arraycopy( originator_id, 0, x, 0, originator_id.length );
		System.arraycopy( value_bytes, 0, x, originator_id.length, value_bytes.length );

		HashWrapper	originator_value_id = new HashWrapper( new SHA1Hasher().calculateHash( x ));

		return( originator_value_id );
		*/
}
Also used : DHTTransportContact(com.biglybt.core.dht.transport.DHTTransportContact) HashWrapper(com.biglybt.core.util.HashWrapper)

Example 15 with HashWrapper

use of com.biglybt.core.util.HashWrapper in project BiglyBT by BiglySoftware.

the class DHTDBMapping method getAnyValue.

protected DHTDBValueImpl getAnyValue(DHTTransportContact originator) {
    DHTDBValueImpl res = null;
    try {
        Map<HashWrapper, DHTDBValueImpl> map = direct_originator_map_may_be_null;
        if (map != null) {
            HashWrapper originator_id = new HashWrapper(originator.getID());
            res = (DHTDBValueImpl) map.get(originator_id);
        }
        if (res == null) {
            Iterator<DHTDBValueImpl> it = indirect_originator_value_map.values().iterator();
            if (it.hasNext()) {
                res = it.next();
            }
        }
    } catch (Throwable e) {
    // slight chance of conc exception here, don't care
    }
    return (res);
}
Also used : HashWrapper(com.biglybt.core.util.HashWrapper)

Aggregations

HashWrapper (com.biglybt.core.util.HashWrapper)17 DownloadManager (com.biglybt.core.download.DownloadManager)5 GlobalManager (com.biglybt.core.global.GlobalManager)4 DHTTransportContact (com.biglybt.core.dht.transport.DHTTransportContact)2 PEPeerManager (com.biglybt.core.peer.PEPeerManager)2 PEPiece (com.biglybt.core.peer.PEPiece)2 UIFunctions (com.biglybt.ui.UIFunctions)2 ActivitiesEntry (com.biglybt.activities.ActivitiesEntry)1 Core (com.biglybt.core.Core)1 ParameterListener (com.biglybt.core.config.ParameterListener)1 TranscodeFile (com.biglybt.core.devices.TranscodeFile)1 TranscodeJob (com.biglybt.core.devices.TranscodeJob)1 DownloadManagerState (com.biglybt.core.download.DownloadManagerState)1 DownloadHistory (com.biglybt.core.history.DownloadHistory)1 PEPeer (com.biglybt.core.peer.PEPeer)1 TagDownload (com.biglybt.core.tag.TagDownload)1 TOTorrent (com.biglybt.core.torrent.TOTorrent)1 TOTorrentException (com.biglybt.core.torrent.TOTorrentException)1 TRTrackerScraperClientResolver (com.biglybt.core.tracker.client.TRTrackerScraperClientResolver)1 IdentityHashSet (com.biglybt.core.util.IdentityHashSet)1