예제 #1
0
        public void AddFile(string name, uint size, byte[] Hash, stDatosFuente[] sources)
        {
            CElement Element;

            if (this.m_Contains(Hash))
            {
                CLog.Log(Constants.Log.Notify, "FIL_DUP", name);
                Element = (CElement)this[Hash];
            }
            else
            {
                CFile file = new CFile(Hash, name, size);
                Element            = new CElement();
                Element.File       = file;
                Element.Statistics = new CFileStatistics();
                m_FileList.Add(Element);
                CKernel.NewFile(Element);
                CLog.Log(Constants.Log.Notify, "FIL_ADDED", name);
            }
            if ((Element.SourcesList == null) && ((Element.File.FileStatus == Protocol.FileState.Ready) || (Element.File.FileStatus == Protocol.FileState.Completing)))
            {
                CSourcesList sourcesList = new CSourcesList(Element);
                Element.SourcesList = sourcesList;
                if (CKernel.ServersList.ActiveServer != null)
                {
                    CKernel.ServersList.ActiveServer.RequestSources(Element.File.FileHash);
                }
            }
            if ((Element.SourcesList != null) &&
                ((Element.File.FileStatus == Protocol.FileState.Ready) || (Element.File.FileStatus == Protocol.FileState.Completing)) &&
                (sources != null))
            {
                CKernel.ClientsList.AddClientsToFile(sources, Hash);
            }
        }
예제 #2
0
 public void AddFile(string name, uint size, byte[] Hash, stDatosFuente[] sources)
 {
     CElement Element;
     if (this.m_Contains(Hash))
     {
         CLog.Log(Constants.Log.Notify,"FIL_DUP",name);
         Element=(CElement)this[Hash];
     }
     else
     {
         CFile file=new CFile(Hash,name,size);
         Element=new CElement();
         Element.File=file;
         Element.Statistics=new CFileStatistics();
         m_FileList.Add(Element);
         CKernel.NewFile(Element);
         CLog.Log(Constants.Log.Notify,"FIL_ADDED",name);
     }
     if ((Element.SourcesList==null)&&((Element.File.FileStatus==Protocol.FileState.Ready)||(Element.File.FileStatus==Protocol.FileState.Completing)))
     {
         CSourcesList sourcesList=new CSourcesList(Element);
         Element.SourcesList=sourcesList;
         if (CKernel.ServersList.ActiveServer!=null) CKernel.ServersList.ActiveServer.RequestSources(Element.File.FileHash);
     }
     if ((Element.SourcesList!=null)&&
         ((Element.File.FileStatus==Protocol.FileState.Ready)||(Element.File.FileStatus==Protocol.FileState.Completing))&&
         (sources!=null))
         CKernel.ClientsList.AddClientsToFile(sources,Hash);
 }