예제 #1
0
 public void StartDownload(string filename, string output_filename, long output_file_length)
 {
     //this.output_filename = output_filename;
     //this.filename = filename;
     queue_entry = new Queue.QueueEntry();
     queue_entry.OutputFilename = output_filename;
     queue_entry.Filesize = output_file_length;
     source = new Queue.QueueEntry.Source();
     source.Filename = filename;
     StartDownload();
 }
예제 #2
0
        public void GetTTHL(Queue.QueueEntry entry)
        {
            //try to download a tthl block if peer offers this via supports
            this.queue_entry = entry;
            //this.source = entry.Sources[0];
            //this.source = source;
            direction = ConnectionDirection.Download;
            long start_pos = 0;
            if (File.Exists(queue_entry.OutputFilename + ".tthl"))
            {
                File.Delete(queue_entry.OutputFilename + ".tthl");//delete old tthl file if happen to be there
            }

            bytes_already_downloaded = 0;
            /*if (File.Exists(queue_entry.OutputFilename))
            {
                FileInfo fi = new FileInfo(queue_entry.OutputFilename);
                if (fi.Length >= queue_entry.Filesize)
                {//abort , file is complete or something else may happened here
                    Disconnect();
                    return;
                }
                start_pos = fi.Length + 1;
                bytes_already_downloaded = fi.Length;
                stream = new FileStream(queue_entry.OutputFilename, FileMode.Append, FileAccess.Write, System.IO.FileShare.ReadWrite);
            }
            else start_pos = 1;
            */

            if (CheckForExtension("ADCGet") && CheckForExtension("TTHL") && CheckForExtension("TTHF") && queue_entry.HasTTH)
            {
                SendCommand("ADCGET", "tthl TTH/" + queue_entry.TTH + " " + start_pos + " -1");
                //SendCommand("ADCGET", "tthl " + source.Filename + " " + start_pos + " -1");
                //Console.WriteLine("Trying to adc-fetch tthl file(" + entry.OutputFilename + ".tthl) from: '" + source.UserName + "'");
                Console.WriteLine("Trying to adc-fetch tthl for file(" + entry.OutputFilename + ")");
            }
            else
            {
                Console.WriteLine("Trying to fetch tthl for file(" + entry.OutputFilename+") from: '" + source.UserName + "' that doesn't support it");
            }
        }
예제 #3
0
 public void StartDownload(Queue.QueueEntry.Source source, Queue.QueueEntry entry)
 {
     this.queue_entry = entry;
     this.source = source;
     StartDownload();
 }
예제 #4
0
        public void GetFileList(Queue.QueueEntry entry)
        {
            //try to download a filelist that the peer offers by his supports
            //it would be fine to have these converted on the spot to our standard filelist format (files.xml.bz2)
            this.queue_entry = entry;
            this.source = entry.Sources[0];//filelist queue entry have exactly one source , no more no less
            direction = ConnectionDirection.Download;
            long start_pos = 1;
            if (File.Exists(queue_entry.OutputFilename))
            {
                File.Delete(queue_entry.OutputFilename);//delete old filelist if happen to be there
            }

            string filename = "MyList.DcLst";
            if (CheckForExtension("XmlBZList"))
                filename = "files.xml.bz2";
            else if (CheckForExtension("BZList"))
                filename = "MyList.bz2";

            source.Filename = filename;

            if (CheckForExtension("ADCGet"))
            {
                start_pos = start_pos - 1;
                SendCommand("ADCGET", "file " + source.Filename + " " + start_pos + " -1");
                Console.WriteLine("Trying to adc-fetch filelist(" + filename + ") from: '" + entry.Sources[0].UserName + "'");
            }
            else
            {
                SendCommand("Get", filename + "$" + start_pos);
                Console.WriteLine("Trying to fetch filelist(" + filename + ") from: '" + entry.Sources[0].UserName + "'");
            }
        }