예제 #1
0
파일: Search.cs 프로젝트: pengpercy/lphant
        public void AddFileFound(byte[] Hash, string name, uint size, uint avaibility, string codec, string length, uint bitrate, bool complete, uint ip, ushort port)
        {
            try
            {
                string strHash = CKernel.HashToString(Hash);

                m_sources += avaibility;
                if (ContainsKey(strHash))
                {
                    CFileFound fileFound = (CFileFound)this[strHash];
                    fileFound.UpdateFile(avaibility, name, codec, length, bitrate, complete, ip, port);
                    CKernel.SearchFileModified(fileFound, (int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
                }
                else
                {
                    CFileFound fileFound = new CFileFound(strHash, name, size, avaibility, codec, length, bitrate, complete, ip, port);
                    Add(strHash, fileFound);
                    CKernel.NewFileFound(fileFound, (int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Search error");
                Debug.WriteLine(e.ToString());
                CKernel.SearchEnded((int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
            }
        }
예제 #2
0
        internal static void NewFileFound(CFileFound file, int SearchIndex)
        {
            InterfaceSearchedFile searchFile = new InterfaceSearchedFile();

            searchFile = InterfaceGateway[0].FileFountToInterfaceFileFound(file);

            for (int i = 0; i <= InterfaceGateway.Length - 1; i++)
            {
                if (CKernel.InterfaceGateway[i] != null)
                {
                    InterfaceGateway[i].NewFileFound(searchFile, SearchIndex);
                }
            }
        }
예제 #3
0
        internal static void SearchFileModified(CFileFound file, int SearchIndex)
        {
            InterfaceSearchedFile searchFile=new InterfaceSearchedFile();
            searchFile=InterfaceGateway[0].FileFountToInterfaceFileFound(file);

            for (int i=0;i<=InterfaceGateway.Length-1;i++)
            {
                if (CKernel.InterfaceGateway[i]!=null)
                {
                    InterfaceGateway[i].SearchFileModified(searchFile, SearchIndex);
                }
            }
        }
예제 #4
0
        public void AddFileFound(byte[] Hash, string name, uint size, uint avaibility, string codec, string length, uint bitrate, bool complete, uint ip, ushort port)
        {
            try
            {
                string strHash=CKernel.HashToString(Hash);

                m_sources += avaibility;
                if (ContainsKey(strHash))
                {
                    CFileFound fileFound=(CFileFound)this[strHash];
                    fileFound.UpdateFile(avaibility,name,codec,length,bitrate,complete,ip,port);
                    CKernel.SearchFileModified(fileFound,(int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
                }
                else
                {
                    CFileFound fileFound=new CFileFound(strHash, name, size, avaibility, codec,length,bitrate,complete,ip,port);
                    Add(strHash,fileFound);
                    CKernel.NewFileFound(fileFound,(int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
                }
            }
            catch(Exception e)
            {
                Debug.WriteLine("Search error");
                Debug.WriteLine(e.ToString());
                CKernel.SearchEnded((int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
            }
        }
예제 #5
0
 internal InterfaceSearchedFile FileFountToInterfaceFileFound(CFileFound file)
 {
     if (apw)
     {
         InterfaceSearchedFile found= new InterfaceSearchedFile();
         found=new InterfaceSearchedFile();
         found.Name=file.Name;
         found.Size=file.Size;
         found.strFileHash=file.Hash;
         found.Avaibility=file.Avaibility;
         found.ResultState=file.ResultState;
         found.Codec=file.Codec;
         found.Length=file.Length;
         found.BitRate=file.BitRate;
         found.Completed=file.Complete;
         return found;
     }
     else return null;
 }