Ejemplo n.º 1
0
        ParseHit(G2PacketH hit, FileLocationFound location)
        {
            // for now we dont take into accounts host of partial files
            if (isPartialFile(hit) && !Settings.ACCEPT_PARTIAL_FILE)
            {
                return(null);
            }

            string FileName = "";
            long   size     = getNameAndSizeFromHit(hit, out FileName);

            if (size == 0)
            {
                return(null);                // no size, no name or bug
            }
            List <URN> Hashes     = getHashesFromHit(hit);
            TypeHash   type       = TypeHash.Md4EDonkey;
            URN        SingleHash = Hashes.Find(FindED2KHash);

            if (SingleHash == null)
            {
                SingleHash = Hashes.Find(FindSHA1Hash);
                type       = TypeHash.Sha1;
            }
            // if there is not the hashes we want , we dont want this packet
            // for now. ActionInnoncence DLL needs to take care of more hashes
            if (SingleHash == null)
            {
                return(null);
            }
            // gives a text representation of the hash
            string strHash = BitConverter.ToString(SingleHash.Digest).Replace("-", string.Empty).ToLower();


            string   link = getDownloadLink(hit);
            Metadata meta = Metadata.ParseMetadata(hit.getStringFromChildType(G2PacketType.MD));


            G2File f = new G2File(FileName, strHash, SingleHash.Digest, type, size,
                                  FileType.Unknow, meta.Codec, location, meta.Length, Settings.PROTOCOL_NAME, link);

            f.Hashes       = Hashes;
            f.CreationTime = getCreationTimeFromHit(hit);
            f.Metadata     = meta;
            f.UserComment  = hit.getStringFromChildType(G2PacketType.COM);
            f.PreviewUrl   = hit.getStringFromChildType(G2PacketType.PVU);
            return(f);
        }
Ejemplo n.º 2
0
        /**
         * Return a File for the application plugin
         * from a Hit Packet
         * */
        public static G2File ParseHit(G2PacketH hit,FileLocationFound location)
        {
            // for now we dont take into accounts host of partial files
            if (isPartialFile(hit) && !Settings.ACCEPT_PARTIAL_FILE)
                return null;

            string FileName = "";
            long size = getNameAndSizeFromHit (hit, out FileName);
            if (size == 0)
                return null; // no size, no name or bug

            List<URN> Hashes = getHashesFromHit (hit);
            TypeHash type = TypeHash.Md4EDonkey;
            URN SingleHash = Hashes.Find (FindED2KHash);
            if (SingleHash == null) {
                SingleHash = Hashes.Find (FindSHA1Hash);
                type = TypeHash.Sha1;
            }
            // if there is not the hashes we want , we dont want this packet
            // for now. ActionInnoncence DLL needs to take care of more hashes
            if (SingleHash == null)
                return null;
            // gives a text representation of the hash
            string strHash = BitConverter.ToString(SingleHash.Digest).Replace("-", string.Empty).ToLower();

            string link = getDownloadLink (hit);
            Metadata meta = Metadata.ParseMetadata(hit.getStringFromChildType(G2PacketType.MD));

            G2File f = new G2File(FileName, strHash, SingleHash.Digest, type, size,
                FileType.Unknow, meta.Codec, location, meta.Length, Settings.PROTOCOL_NAME, link);

            f.Hashes = Hashes;
            f.CreationTime = getCreationTimeFromHit(hit);
            f.Metadata = meta;
            f.UserComment = hit.getStringFromChildType(G2PacketType.COM);
            f.PreviewUrl = hit.getStringFromChildType( G2PacketType.PVU);
            return f;
        }