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); }
public void m_OnNewChatMessage(InterfaceClient source, string message) { if (OnNewChatMessage!=null) OnNewChatMessage(source, message); }
public void m_OnNewUpload(InterfaceClient client) { if (OnNewUpload!=null) OnNewUpload(client); }
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); }
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); }
private void m_InvokeOnNewUpload(InterfaceClient client) { this.BeginInvoke(new ClientEvent(m_OnNewUpload),new object[] {client}); }
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; }
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; }
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; }
internal void NewUpload(InterfaceClient client) { if (apw) if (client!=null) SubmitOnNewUpload(client); }
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; }
internal void NewSource(InterfaceClient client,string strDownFileHash) { if (apw) if (client!=null) SubmitOnNewSource(client,strDownFileHash); }
internal InterfaceClient ClientToInterfaceClient(CClient Client) { if (apw) { InterfaceClient response=new InterfaceClient(); response.Name=Client.UserName; if (Client.IsPartner) response.Name="(partner) "+response.Name; 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; }
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(); }
private void m_InvokeOnStartChatSession(InterfaceClient client) { m_LastChatMessage=client.Name; MethodInvoker mi = new MethodInvoker(this.m_StartCharSession); this.BeginInvoke(mi); }
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; }
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; }
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; }
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); }
public virtual void SubmitOnNewSource(InterfaceClient source,string strFileHashDescarga) { if (OnNewSource!=null) OnNewSource(source,strFileHashDescarga); }
private void m_InvokeOnNewSource(InterfaceClient source,string strHashFicheroDescarga) { this.BeginInvoke(new SourceEvent(m_OnNewSource),new object[] {source,strHashFicheroDescarga}); }
public virtual void SubmitOnNewUpload(InterfaceClient client) { if (OnNewUpload!=null) OnNewUpload(client); }
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); }
private void m_InvokeOnAddingFriend(InterfaceClient client) { m_LastChatMessage=client.Name; MethodInvoker mi = new MethodInvoker(this.m_AddingFriend); this.BeginInvoke(mi); }
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); }
private void m_InvokeOnDeleteFriend(InterfaceClient client) { MethodInvoker mi = new MethodInvoker(this.m_DeleteFriend); this.BeginInvoke(mi); }
public void m_OnNewSource(InterfaceClient client,string strFileHash) { if (OnNewSource!=null) OnNewSource(client,strFileHash); }
private void m_InvokeOnNewChatMessage(InterfaceClient client, string message) { m_LastChatMessage=client.Name+":"+message; MethodInvoker mi = new MethodInvoker(this.m_StartCharSession); this.BeginInvoke(mi); }
public void StartChatSession(InterfaceClient source) { if (OnStartChatSession!=null) OnStartChatSession(source); }
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); }