Exemplo n.º 1
0
 private void OnViewFiles(object sender, System.EventArgs e)
 {
     if (listViewFriends.SelectedItems.Count<=0) return;
     int index = listViewFriends.SelectedIndices[0];
     InterfaceClient source = new InterfaceClient();
     source.ID	= m_Friends[index].ID;
     source.Name	= m_Friends[index].Name;
     if (m_Friends[index].OurName!="") source.Name=m_Friends[index].OurName;
     source.Port = m_Friends[index].Port;
     source.ServerIP	= m_Friends[index].ServerIP;
     source.Software = m_Friends[index].Software;
     source.Version	= m_Friends[index].Version;
     source.UserHash	= m_Friends[index].UserHash;
     krnGateway.RequestSharedList(source.ID,source.Port,source.ServerIP,source.UserHash);
 }
Exemplo n.º 2
0
        public InterfaceClient[] GetFileSources(string strFileHash)
        {
            if (apw)
            {
                CElement Element=(CElement)CKernel.FilesList[CKernel.StringToHash(strFileHash)];
                if ((Element==null)||(Element.SourcesList==null)||(Element.SourcesList.Count()==0)) return null;
                InterfaceClient[] response=new InterfaceClient[Element.SourcesList.Count()];
                int i=0;
                lock(Element.SourcesList.SyncRoot())
                {
                    foreach (CClient Client in Element.SourcesList)
                    {
                        response[i]=ClientToInterfaceClient(Client);
                        i++;
                    }
                }
                return response;

            }
            else return null;
        }
Exemplo n.º 3
0
 public InterfaceClient GetUploadClient(uint ID, ushort Port,uint ServerIP, byte[] ClientHash)
 {
     if (apw)
     {
         CClient Client=CKernel.ClientsList.GetClient(ID,Port,ServerIP,ClientHash);
         if (Client!=null)
         {
             if (CKernel.Queue.UploadList.Contains(Client))
             {
                 InterfaceClient response=new InterfaceClient();
                 response=ClientToInterfaceClient(Client);
                 return response;
             }
         }
         return null;
     }
     else return null;
 }
Exemplo n.º 4
0
        internal InterfaceClient ClientToInterfaceClient(CClient Client)
        {
            if (apw)
            {
                InterfaceClient response=new InterfaceClient();
                response.Name=Client.UserName;
            #if DEBUG
                if (Client.IsPartner) response.Name="(partner) "+response.Name;
            #endif
                response.DownFileName=Client.ClientFileName;
                if ((Client.UploadElement!=null)&&(Client.UploadElement.File!=null))
                    response.UpFileName=Client.UploadElement.File.FileName;
                else
                    response.UpFileName="";
                response.ID=Client.UserID;
                response.Port=Client.Port;
                response.ServerIP=Client.ServerIP;
                response.Software=Client.Software;
                response.Version=Client.Version;
                response.DownloadState=(byte)Client.DownloadState;
                response.UploadState=(byte)Client.UploadState;
                response.UploadRequests=Client.UploadRequests;
                response.UploadedBytes=Client.UploadedBytes;
                response.DownloadedBytes=Client.DownloadedBytes;
                response.LastUploadRequest=Client.LastUploadRequest;
                response.QueueTime=Client.QueueInTime;
                response.DownloadSpeed=(float)Math.Round((Client.DownloadSpeed/1024F),1);
                response.UploadSpeed=Client.UploadSpeed;
                response.DownQR=Client.QRDownload;
                response.DownFileChunks=Client.DownFileChunks;
                response.UpFileChunks=Client.UpFileChunks;
                response.UserHash=Client.UserHash;

                return response;
            }
            else return null;
        }
Exemplo n.º 5
0
 internal void NewUpload(InterfaceClient client)
 {
     if (apw)
         if (client!=null) SubmitOnNewUpload(client);
 }
Exemplo n.º 6
0
 public void m_OnNewUpload(InterfaceClient client)
 {
     if (OnNewUpload!=null) OnNewUpload(client);
 }
Exemplo n.º 7
0
 public virtual void SubmitOnNewSource(InterfaceClient source,string strFileHashDescarga)
 {
     if (OnNewSource!=null) OnNewSource(source,strFileHashDescarga);
 }
Exemplo n.º 8
0
 private void m_InvokeOnNewChatMessage(InterfaceClient client, string message)
 {
     m_LastChatMessage=client.Name+":"+message;
     MethodInvoker mi = new MethodInvoker(this.m_StartCharSession);
     this.BeginInvoke(mi);
 }
Exemplo n.º 9
0
 private void m_InvokeOnStartChatSession(InterfaceClient client)
 {
     m_LastChatMessage=client.Name;
     MethodInvoker mi = new MethodInvoker(this.m_StartCharSession);
     this.BeginInvoke(mi);
 }
Exemplo n.º 10
0
 private void m_InvokeOnAddingFriend(InterfaceClient client)
 {
     m_LastChatMessage=client.Name;
     MethodInvoker mi = new MethodInvoker(this.m_AddingFriend);
     this.BeginInvoke(mi);
 }
Exemplo n.º 11
0
 private void m_InvokeOnDeleteFriend(InterfaceClient client)
 {
     MethodInvoker mi = new MethodInvoker(this.m_DeleteFriend);
     this.BeginInvoke(mi);
 }
Exemplo n.º 12
0
        private void m_OnNewUpload(InterfaceClient client)
        {
            //we fist check if the upload is in the list, possible when interface is sleeping and a deleted source
            //is added again (the deleted source was not really removed because interface was sleeping
            foreach (ListViewItem item in Items)
            {
                if ((((InterfaceClient)item.Tag).ID==client.ID)&&
                    (((InterfaceClient)item.Tag).Port==client.Port))
                    return;
            }

            ListViewItem itemUpload=new ListViewItem(new string[]{"","","","","","","","",""});

            itemUpload.Tag=client;
            ClientToItem(client,itemUpload);
            Items.Add(itemUpload);
        }
Exemplo n.º 13
0
 private void m_InvokeOnNewUpload(InterfaceClient client)
 {
     this.BeginInvoke(new ClientEvent(m_OnNewUpload),new object[] {client});
 }
Exemplo n.º 14
0
 private void ClientToItem(InterfaceClient client,ListViewItem itemUpload)
 {
     if (client==null) return;
     if (itemUpload.SubItems[0].Text!=client.Name)
         itemUpload.SubItems[0].Text=client.Name;
     if (itemUpload.SubItems[1].Text!=client.UpFileName)
         itemUpload.SubItems[1].Text=client.UpFileName;
     if (itemUpload.SubItems[2].Text!=SpeedToString(client.UploadSpeed))
         itemUpload.SubItems[2].Text=SpeedToString(client.UploadSpeed);
     if (itemUpload.SubItems[3].Text!=SizeToString(client.UploadedBytes))
         itemUpload.SubItems[3].Text=SizeToString(client.UploadedBytes);
     if (itemUpload.SubItems[4].Text!=SizeToString(client.DownloadedBytes))
         itemUpload.SubItems[4].Text=SizeToString(client.DownloadedBytes);
     if (itemUpload.SubItems[5].Text!=StatusToString(client.UploadState))
         itemUpload.SubItems[5].Text=StatusToString(client.UploadState);
     if (itemUpload.SubItems[6].Text!="")
         itemUpload.SubItems[6].Text=""; //progress
     if (itemUpload.SubItems[7].Text!=client.Software)
         itemUpload.SubItems[7].Text=client.Software;
     //			if (client.Software=="eMule")
     //			{
     //				if (itemUpload.SubItems[8].Text!=client.Version.ToString("X"))
     //					itemUpload.SubItems[8].Text=client.Version.ToString("X");
     //			}
     //			else
     //			{
     float div=100F;
     if (client.Software=="eDonkeyHybrid") div=1000F;
     if (itemUpload.SubItems[8].Text!=(client.Version/div).ToString("0.00"))
             itemUpload.SubItems[8].Text=(client.Version/div).ToString("0.00");
     //			}
     itemUpload.Tag=client;
 }
Exemplo n.º 15
0
 public void m_OnNewChatMessage(InterfaceClient source, string message)
 {
     if (OnNewChatMessage!=null) OnNewChatMessage(source, message);
 }
Exemplo n.º 16
0
		private void SourceToItem(InterfaceClient source,ListViewItem itemSource)
		{
			if (source==null) return;
			if (itemSource.SubItems[0].Text!=source.Name) 
				itemSource.SubItems[0].Text=source.Name;
			if (itemSource.SubItems[1].Text!=source.DownFileName) 
				itemSource.SubItems[1].Text=source.DownFileName;
			if (itemSource.SubItems[2].Text!=SpeedToString(source.DownloadSpeed)) 
				itemSource.SubItems[2].Text=SpeedToString(source.DownloadSpeed);
			if (itemSource.SubItems[3].Text!=StatusToString(source.DownloadState)) 
				itemSource.SubItems[3].Text=StatusToString(source.DownloadState);
			if (itemSource.SubItems[4].Text!=Convert.ToString(source.DownQR)) 
				itemSource.SubItems[4].Text=Convert.ToString(source.DownQR);
			if (itemSource.SubItems[5].Text!=SizeToString(source.DownloadedBytes)) 
				itemSource.SubItems[5].Text=SizeToString(source.DownloadedBytes);
			if (itemSource.SubItems[6].Text!=SizeToString(source.UploadedBytes)) 
				itemSource.SubItems[6].Text=SizeToString(source.UploadedBytes);
			if (itemSource.SubItems[7].Text!="") 
				itemSource.SubItems[7].Text=""; //progress
			if (itemSource.SubItems[8].Text!=source.Software) 
				itemSource.SubItems[8].Text=source.Software;
//			if (source.Software=="eMule")
//			{
//				if (itemSource.SubItems[9].Text!=source.Version.ToString("X")) 
//					itemSource.SubItems[9].Text=source.Version.ToString("X");
//			}
//			else
//			{
			float div=100F;
			if (source.Software=="eDonkeyHybrid") div=1000F;	
			if (itemSource.SubItems[9].Text!=(source.Version/div).ToString("0.00")) 
					itemSource.SubItems[9].Text=(source.Version/div).ToString("0.00");
//			}
			itemSource.Tag=source;
		}
Exemplo n.º 17
0
 public void m_OnNewSource(InterfaceClient client,string strFileHash)
 {
     if (OnNewSource!=null) OnNewSource(client,strFileHash);
 }
Exemplo n.º 18
0
		private void m_InvokeOnNewSource(InterfaceClient source,string strHashFicheroDescarga)
		{
			this.BeginInvoke(new SourceEvent(m_OnNewSource),new object[] {source,strHashFicheroDescarga});
		}
Exemplo n.º 19
0
 public void StartChatSession(InterfaceClient source)
 {
     if (OnStartChatSession!=null) OnStartChatSession(source);
 }
Exemplo n.º 20
0
		private void m_OnNewSource(InterfaceClient source,string strHashFicheroDescarga)
		{
			if (strHashFicheroDescarga!=strFileHash) return;
			ListViewItem itemSource=new ListViewItem(new string[]{"","","","","","","","","",""});
			
			itemSource.Tag=source;
			SourceToItem(source,itemSource);
			Items.Add(itemSource);
		}
Exemplo n.º 21
0
 public virtual void SubmitOnNewUpload(InterfaceClient client)
 {
     if (OnNewUpload!=null) OnNewUpload(client);
 }
Exemplo n.º 22
0
 private void ClientToItem(InterfaceClient client,ListViewItem itemUpload)
 {
     if (client==null) return;
     if (itemUpload.SubItems[0].Text!=client.Name)
         itemUpload.SubItems[0].Text=client.Name;
     if (itemUpload.SubItems[1].Text!=client.UpFileName)
         itemUpload.SubItems[1].Text=client.UpFileName;
     if (itemUpload.SubItems[2].Text!=SizeToString(client.UploadedBytes))
         itemUpload.SubItems[2].Text=SizeToString(client.UploadedBytes);
     if (itemUpload.SubItems[3].Text!=SizeToString(client.DownloadedBytes))
         itemUpload.SubItems[3].Text=SizeToString(client.DownloadedBytes);
     if (itemUpload.SubItems[4].Text!=StatusToString(client.UploadState))
         itemUpload.SubItems[4].Text=StatusToString(client.UploadState);
     if (itemUpload.SubItems[5].Text!="")
         itemUpload.SubItems[5].Text=""; //progress
     if (itemUpload.SubItems[6].Text!=client.Software)
         itemUpload.SubItems[6].Text=client.Software;
     if (itemUpload.SubItems[7].Text!=client.Version.ToString())
         itemUpload.SubItems[7].Text=client.Version.ToString();
 }
Exemplo n.º 23
0
 internal void NewSource(InterfaceClient client,string strDownFileHash)
 {
     if (apw)
         if (client!=null) SubmitOnNewSource(client,strDownFileHash);
 }
Exemplo n.º 24
0
 public void AddFriend(InterfaceClient source)
 {
     krnGateway.AddFriend(source.ID, source.Port, source.ServerIP, source.UserHash, 0, "", source.Name, source.Software, source.Version,false);
     OnAddingFriend(source);
 }
Exemplo n.º 25
0
        public InterfaceClient GetDownloadClient(uint ID, ushort Port,uint ServerIP, byte[] ClientHash,string strDownFileHash)
        {
            if (apw)
            {
                CElement Element=CKernel.FilesList[CKernel.StringToHash(strDownFileHash)];
                if ((Element==null)||(Element.SourcesList==null)) return null;
                CClient client=Element.SourcesList.GetSource(ID,Port,ServerIP,ClientHash);
                if (client==null) return null;
                InterfaceClient response=new InterfaceClient();
                response=ClientToInterfaceClient(client);
                return response;

            //				CClient Client=CKernel.ClientsList.GetClient(ID,Port,ServerIP,ClientHash);
            //				if ((Client!=null)&&(Client.DownFileHash!=null)&&(CKernel.HashToString(Client.DownFileHash)==strDownFileHash))
            //				{
            //					InterfaceClient response=new InterfaceClient();
            //					response=ClientToInterfaceClient(Client);
            //					return response;
            //				}
            //				else return null;
            }
            else return null;
        }
Exemplo n.º 26
0
 public void AddFriend(SFriend friend)
 {
     krnGateway.AddFriend(friend.ID, friend.Port, friend.ServerIP, friend.UserHash, 0, friend.OurName, friend.Name, friend.Software, friend.Version, friend.FriendSlot);
     InterfaceClient source = new InterfaceClient();
     source.Name=friend.OurName;
     source.ID=friend.ID;
     source.Port=friend.Port;
     if (friend.UserHash!=null) source.UserHash=friend.UserHash;
     OnAddingFriend(source);
 }
Exemplo n.º 27
0
 public InterfaceClient[] GetQueuedSourcesList(byte[] fileHashFilter)
 {
     if (apw)
     {
         ArrayList sourceslist=new ArrayList();
         lock (CKernel.Queue.List.SyncRoot)
         {
             foreach (CClient Client in CKernel.Queue.List)
             {
                 if ((fileHashFilter==null)||(CKernel.SameHash(ref fileHashFilter, ref Client.UploadElement.File.FileHash)))
                 {
                     sourceslist.Add(ClientToInterfaceClient(Client));
                 }
             }
         }
         InterfaceClient[] response=new InterfaceClient[sourceslist.Count];
         for (int i=0;i<sourceslist.Count;i++)
         {
             response[i]=(InterfaceClient)sourceslist[i];
         }
         return response;
     }
     else return null;
 }
Exemplo n.º 28
0
 public void DeleteFriend(byte[] ClientHash,uint ID, ushort Port)
 {
     krnGateway.DeleteFriend(ClientHash, ID, Port);
     InterfaceClient source = new InterfaceClient();
     source.ID=ID;
     source.UserHash=ClientHash;
     source.Port=Port;
     OnDeleteFriend(source);
 }
Exemplo n.º 29
0
 public InterfaceClient[] GetUploadingSources()
 {
     if (apw)
     {
         InterfaceClient[] response=new InterfaceClient[CKernel.Queue.UploadList.Count];
         int i=0;
         foreach (CClient Client in CKernel.Queue.UploadList)
         {
             response[i]=ClientToInterfaceClient(Client);
             i++;
         }
         return response;
     }
     else return null;
 }
Exemplo n.º 30
0
 private void OnSendMessage(object sender, System.EventArgs e)
 {
     if (listViewFriends.SelectedItems.Count<=0) return;
     int index = listViewFriends.SelectedIndices[0];
     InterfaceClient source = new InterfaceClient();
     source.ID	= m_Friends[index].ID;
     source.Name	= m_Friends[index].Name;
     if (m_Friends[index].OurName!="") source.Name=m_Friends[index].OurName;
     source.Port = m_Friends[index].Port;
     source.ServerIP	= m_Friends[index].ServerIP;
     source.Software = m_Friends[index].Software;
     source.Version	= m_Friends[index].Version;
     source.UserHash	= m_Friends[index].UserHash;
     krnGateway.StartChatSession(source);
 }