I2P

Invisible Internet Project


Changeset 3fb1afe4edce3fd7fcf12e4a975e612089a8aebd

Show
Ignore:
Timestamp:
02/04/12 22:46:40 (16 months ago)
Author:
mkvore-commit@…
Branches:
i2p.imule.v2
Children:
e44fc65862bdaea1e12d837635b4eef7910b9365
Parents:
183e411556713f7079dabf1e90a640900e5fb455
Message:

UploadClient? merged. Not compiled.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • /src/UploadClient.cpp

    r183e.. r3fb1..  
    2424// 
    2525 
     26#include "updownclient.h"       // Interface 
     27 
     28#include <protocol/Protocols.h> 
     29#include <protocol/ed2k/Client2Client/TCP.h> 
     30 
    2631#include <zlib.h> 
    27 #include <cmath>                // Needed for std::exp 
    28  
    29 #include "OtherFunctions.h"     // Needed for nstrdup 
    30  
    31 #include "ClientUDPSocket.h"    // Needed for CClientUDPSocket 
     32 
    3233#include "ClientCredits.h"      // Needed for CClientCredits 
    3334#include "Packet.h"             // Needed for CPacket 
     
    3536#include "UploadQueue.h"        // Needed for CUploadQueue 
    3637#include "DownloadQueue.h"      // Needed for CDownloadQueue 
    37 #include "Preferences.h"        // Needed for CPreferences 
    38 #include "OtherStructs.h"       // Needed for Requested_Block_Struct 
    39 #include "ServerConnect.h"              // Needed for CServerConnect 
    4038#include "PartFile.h"           // Needed for PR_POWERSHARE 
    41 #include "KnownFile.h"          // Needed for CKnownFile 
    42 #include "KnownFileList.h"              // Needed for CKnownFileLists 
    4339#include "ClientTCPSocket.h"    // Needed for CClientTCPSocket 
    4440#include "SharedFileList.h"     // Needed for CSharedFileList 
    4541#include "imule.h"              // Needed for theApp 
    46 #include "BarShader.h"          // Needed for CBarShader 
    47 #include "updownclient.h"       // Needed for CUpDownClient 
    4842#include "ClientList.h" 
    4943#include "Statistics.h"         // Needed for theStats 
    50 #include "GuiEvents.h"          // Needed for Nofify_... macros 
    5144#include "Logger.h" 
    5245#include <common/Format.h> 
    53 #include "ScopedPtr.h" 
    54 #include <protocol/ed2k/Constants.h> 
    55 #include <protocol/ed2k/Client2Client/TCP.h> 
     46#include "ScopedPtr.h"          // Needed for CScopedArray 
     47#include "GuiEvents.h"          // Needed for Notify_* 
     48 
    5649 
    5750//      members of CUpDownClient 
     
    8174 
    8275#ifndef CLIENT_GUI 
    83 uint32_t CUpDownClient::GetScore(bool sysvalue, bool isdownloading, bool onlybasevalue) const 
    84 { 
    85         //TODO: complete this (friends, uploadspeed, imuleuser etc etc) 
     76uint32 CUpDownClient::GetScore(bool sysvalue, bool isdownloading, bool onlybasevalue) const 
     77{ 
     78        //TODO: complete this (friends, uploadspeed, amuleuser etc etc) 
    8679        if (m_Username.IsEmpty()) { 
    8780                return 0; 
     
    168161                fBaseValue *= 0.5f; 
    169162        } 
    170         return (uint32_t)fBaseValue; 
     163        return (uint32)fBaseValue; 
    171164} 
    172165#endif 
     
    182175         
    183176        // Check if we have good lists and proceed to check for different chunks 
    184         if (!m_BlockRequests_queue.empty() && !m_DoneBlocks_list.empty()) 
     177        if ((!m_BlockRequests_queue.empty()) && !m_DoneBlocks_list.empty()) 
    185178        { 
    186179                Requested_Block_Struct* last_done_block = NULL; 
     
    191184                         
    192185                // Get last block and next pending 
    193         last_done_block = (Requested_Block_Struct*)m_DoneBlocks_list.front(); 
    194         next_requested_block = (Requested_Block_Struct*)m_BlockRequests_queue.front();  
     186                last_done_block = m_DoneBlocks_list.front(); 
     187                next_requested_block = m_BlockRequests_queue.front(); 
    195188                         
    196189                // Calculate corresponding parts to blocks 
     
    201194                if ( last_done_part != next_requested_part) {  
    202195                        different_part = true; 
    203                         AddDebugLogLineM(false, logClient, CFormat(wxT("%x :Session ended due to new chunk.")) % (long) this); 
     196                        AddDebugLogLineM(false, logClient, wxT("Session ended due to new chunk.")); 
    204197                } 
    205198         
    206199                if (md4cmp(last_done_block->FileID, next_requested_block->FileID) != 0) {  
    207200                        different_part = true; 
    208                         AddDebugLogLineM(false, logClient, CFormat(wxT("%x :Session ended due to different file.")) % (long) this); 
     201                        AddDebugLogLineM(false, logClient, wxT("Session ended due to different file.")); 
    209202                } 
    210203        }  
     
    226219        try { 
    227220        // Buffer new data if current buffer is less than 100 KBytes 
    228         while (!m_BlockRequests_queue.empty() && 
     221        while ((!m_BlockRequests_queue.empty()) && 
    229222               (m_addedPayloadQueueSession <= GetQueueSessionPayloadUp() || m_addedPayloadQueueSession-GetQueueSessionPayloadUp() < 100*1024)) { 
    230223 
     
    237230 
    238231                        if (srcfile->IsPartFile() && ((CPartFile*)srcfile)->GetStatus() != PS_COMPLETE) { 
    239 //TODO                          #warning This seems a good idea from eMule. We must import this. 
     232                                //#warning This seems a good idea from eMule. We must import this. 
    240233                                #if 0 
    241234                                // Do not access a part file, if it is currently moved into the incoming directory. 
     
    257250            } 
    258251                 
    259                         size_t togo; 
     252                        uint64 togo; 
    260253            // THIS EndOffset points BEHIND the last byte requested 
    261254            // (other than the offsets used in the PartFile code) 
     
    265258                throw wxString(wxT("Asked for invalid block (start > end)")); 
    266259            } else { 
    267                 if (currentblock->EndOffset - currentblock->StartOffset >= (1<<sizeof(size_t))) 
    268                     throw wxString(wxT("Asked for a huge block")); 
    269                  
    270                 togo = (size_t) (currentblock->EndOffset - currentblock->StartOffset); 
     260                                togo = currentblock->EndOffset - currentblock->StartOffset; 
    271261                 
    272262                if (srcfile->IsPartFile() && !((CPartFile*)srcfile)->IsComplete(currentblock->StartOffset,currentblock->EndOffset-1)) { 
     
    275265            } 
    276266 
    277                         if (togo > (EMBLOCKSIZE * 3)) { 
     267                        if (togo > EMBLOCKSIZE * 3) { 
    278268                                throw wxString(wxT("Client requested too large of a block.")); 
    279269                        } 
    280270                         
    281             CScopedArray<uint8_t> filedata(NULL); 
     271                        CScopedArray<byte> filedata(NULL);       
    282272            if (!srcfile->IsPartFile()){ 
    283273                if ( !file.Open(fullname, CFile::read) ) { 
     
    292282                file.Seek(currentblock->StartOffset, wxFromStart); 
    293283                 
    294                 filedata.reset(new uint8_t[togo + 500]); 
     284                                filedata.reset(new byte[togo + 500]); 
    295285                file.Read(filedata.get(), togo); 
    296286                file.Close(); 
     
    299289                partfile->m_hpartfile.Seek(currentblock->StartOffset); 
    300290                 
    301                 filedata.reset(new uint8_t[togo + 500]); 
     291                                filedata.reset(new byte[togo + 500]); 
    302292                partfile->m_hpartfile.Read(filedata.get(), togo); 
    303293                // Partfile should NOT be closed!!! 
    304294            } 
    305295 
    306  
    307 //TODO                  #warning Part of the above import. 
     296                        //#warning Part of the above import. 
    308297                        #if 0 
    309298                        if (lockFile.m_pObject){ 
     
    335324                return; 
    336325        } catch (const wxString& error) { 
    337                 AddDebugLogLineM(false, logClient, CFormat(wxT("%x :Client '")) % (long) this + GetUserName() + wxT("' caused error while creating packet (") + error + wxT(") - disconnecting client")); 
     326                AddDebugLogLineM(false, logClient, wxT("Client '") + GetUserName() + wxT("' caused error while creating packet (") + error + wxT(") - disconnecting client")); 
    338327        } catch (const CIOFailureException& error) { 
    339                 AddDebugLogLineM(true, logClient, CFormat(wxT("%x :IO failure while reading requested file: ")) % (long) this + error.what()); 
    340         } catch (const CEOFException& error) { 
     328                AddDebugLogLineM(true, logClient, wxT("IO failure while reading requested file: ") + error.what()); 
     329        } catch (const CEOFException& WXUNUSED(error)) { 
    341330                AddDebugLogLineM(true, logClient, GetClientFullInfo() + wxT(" requested file-data at an invalid position - disconnecting")); 
    342331        } 
     
    347336 
    348337 
    349 void CUpDownClient::CreateStandartPackets(const uint8_t* buffer, uint32_t togo, Requested_Block_Struct* currentblock) 
    350 { 
    351         uint32_t nPacketSize; 
    352  
    353         CMemFile memfile((uint8_t*)buffer, togo); 
     338void CUpDownClient::CreateStandartPackets(const byte* buffer, uint32 togo, Requested_Block_Struct* currentblock) 
     339{ 
     340        uint32 nPacketSize; 
     341 
     342        CMemFile memfile(buffer, togo); 
    354343        if (togo > 10240) { 
    355                 nPacketSize = togo/(uint32_t)(togo/10240); 
     344                nPacketSize = togo/(uint32)(togo/10240); 
    356345        } else { 
    357346                nPacketSize = togo; 
     
    366355                togo -= nPacketSize; 
    367356                 
    368                 CMemFile data(nPacketSize+32); 
     357                uint64 endpos = (currentblock->EndOffset - togo); 
     358                uint64 startpos = endpos - nPacketSize; 
     359                 
     360                 
     361                CMemFile data(nPacketSize + 16 + 2 * (bLargeBlocks ? 8 :4)); 
    369362                data.WriteHash(GetUploadFileID()); 
    370                 data.WriteUInt64(((currentblock->EndOffset - togo) - nPacketSize)); 
    371                 data.WriteUInt64(((currentblock->EndOffset - togo))); 
     363                if (bLargeBlocks) { 
     364                        data.WriteUInt64(startpos); 
     365                        data.WriteUInt64(endpos); 
     366                } else { 
     367                        data.WriteUInt32(startpos); 
     368                        data.WriteUInt32(endpos); 
     369                } 
    372370                char *tempbuf = new char[nPacketSize]; 
    373371                memfile.Read(tempbuf, nPacketSize); 
    374372                data.Write(tempbuf, nPacketSize); 
    375373                delete [] tempbuf; 
    376                 CPacket* packet = new CPacket(data,OP_EDONKEYPROT,OP_SENDINGPART); 
    377          
    378                 theStats::AddUpOverheadFileRequest(24); 
     374                CPacket* packet = new CPacket(data, (bLargeBlocks ? OP_EMULEPROT : OP_EDONKEYPROT), (bLargeBlocks ? (uint8)OP_SENDINGPART_I64 : (uint8)OP_SENDINGPART));         
     375                theStats::AddUpOverheadFileRequest(16 + 2 * (bLargeBlocks ? 8 :4)); 
    379376                theStats::AddUploadToSoft(GetClientSoft(), nPacketSize); 
     377                AddDebugLogLineM( false, logLocalClient, wxString::Format(wxT("Local Client: %s to "),(bLargeBlocks ? wxT("OP_SENDINGPART_I64") : wxT("OP_SENDINGPART"))) + GetFullIP() ); 
    380378                m_socket->SendPacket(packet,true,false, nPacketSize); 
    381379        } 
     
    383381 
    384382 
    385 void CUpDownClient::CreatePackedPackets(const uint8_t* buffer, uint32_t togo, Requested_Block_Struct* currentblock) 
    386 { 
    387         uint8_t* output = new uint8_t[togo+300]; 
     383void CUpDownClient::CreatePackedPackets(const byte* buffer, uint32 togo, Requested_Block_Struct* currentblock) 
     384{ 
     385        byte* output = new byte[togo+300]; 
    388386        uLongf newsize = togo+300; 
    389         uint32_t result = compress2(output, &newsize, buffer, togo, 9); 
    390         wxASSERT( result <= (uint16_t) -1 ); 
     387        uint16 result = compress2(output, &newsize, buffer, togo,9); 
    391388        if (result != Z_OK || togo <= newsize){ 
    392389                delete[] output; 
     
    397394        CMemFile memfile(output,newsize); 
    398395         
    399         uint32_t totalPayloadSize = 0; 
    400         uint32_t oldSize = togo; 
     396        uint32 totalPayloadSize = 0; 
     397        uint32 oldSize = togo; 
    401398        togo = newsize; 
    402         uint32_t nPacketSize; 
     399        uint32 nPacketSize; 
    403400        if (togo > 10240) { 
    404                 nPacketSize = togo/(uint32_t)(togo/10240); 
     401                nPacketSize = togo/(uint32)(togo/10240); 
    405402        } else { 
    406403                nPacketSize = togo; 
     
    413410                togo -= nPacketSize; 
    414411 
    415                 CMemFile data(nPacketSize+24); 
     412                 
     413                CMemFile data(nPacketSize + 16 + (isLargeBlock ? 12 : 8)); 
    416414                data.WriteHash(GetUploadFileID()); 
     415                if (isLargeBlock) { 
    417416                data.WriteUInt64(currentblock->StartOffset); 
     417                } else { 
     418                        data.WriteUInt32(currentblock->StartOffset); 
     419                } 
    418420                data.WriteUInt32(newsize);                       
    419421                char *tempbuf = new char[nPacketSize]; 
     
    421423                data.Write(tempbuf,nPacketSize); 
    422424                delete [] tempbuf; 
    423                 CPacket* packet = new CPacket(data, OP_EMULEPROT, OP_COMPRESSEDPART); 
     425                CPacket* packet = new CPacket(data, OP_EMULEPROT, (isLargeBlock ? OP_COMPRESSEDPART_I64 : OP_COMPRESSEDPART)); 
    424426         
    425427                // approximate payload size 
    426                 uint32_t payloadSize = nPacketSize*oldSize/newsize; 
     428                uint32 payloadSize = nPacketSize*oldSize/newsize; 
    427429 
    428430                if (togo == 0 && totalPayloadSize+payloadSize < oldSize) { 
     
    435437                theStats::AddUpOverheadFileRequest(24); 
    436438                theStats::AddUploadToSoft(GetClientSoft(), nPacketSize); 
     439                AddDebugLogLineM( false, logLocalClient, wxString::Format(wxT("Local Client: %s to "), (isLargeBlock ? wxT("OP_COMPRESSEDPART_I64") : wxT("OP_COMPRESSEDPART"))) + GetFullIP() ); 
    437440                m_socket->SendPacket(packet,true,false, payloadSize);                    
    438441        } 
     
    471474         
    472475                try { 
    473                         uint16_t done = 0; 
     476                        uint16 done = 0; 
    474477                        while (done != m_upPartStatus.size()) { 
    475                                 uint8_t toread = data->ReadUInt8(); 
    476                                 for (int32_t i = 0;i != 8;i++){ 
     478                                uint8 toread = data->ReadUInt8(); 
     479                                for (sint32 i = 0;i != 8;i++){ 
    477480                                        m_upPartStatus[done] = (toread>>i)&1; 
    478481                                        //      We may want to use this for another feature.. 
     
    493496 
    494497                if (GetExtendedRequestsVersion() > 1) { 
    495                         uint16_t nCompleteCountLast = GetUpCompleteSourcesCount(); 
    496                         uint16_t nCompleteCountNew = data->ReadUInt16(); 
     498                        uint16 nCompleteCountLast = GetUpCompleteSourcesCount(); 
     499                        uint16 nCompleteCountNew = data->ReadUInt16(); 
    497500                        SetUpCompleteSourcesCount(nCompleteCountNew); 
    498501                        if (nCompleteCountLast != nCompleteCountNew) { 
     
    572575} 
    573576 
    574 uint32_t CUpDownClient::GetWaitStartTime() const 
    575 { 
    576         uint32_t dwResult = 0; 
     577 
     578uint32 CUpDownClient::GetWaitStartTime() const 
     579{ 
     580        uint32 dwResult = 0; 
    577581         
    578582        if ( credits ) { 
     
    605609 
    606610 
    607 uint32_t CUpDownClient::SendBlockData() 
    608 { 
    609     uint32_t curTick = ::GetTickCount(); 
    610     uint64_t sentBytesCompleteFile = 0; 
    611     uint64_t sentBytesPartFile = 0; 
    612     uint64_t sentBytesPayload = 0; 
    613  
    614         if ( m_socket ) 
    615         { 
     611uint32 CUpDownClient::SendBlockData() 
     612{ 
     613    uint32 curTick = ::GetTickCount(); 
     614    uint64 sentBytesCompleteFile = 0; 
     615    uint64 sentBytesPartFile = 0; 
     616    uint64 sentBytesPayload = 0; 
     617 
     618    if (m_socket) { 
    616619                CEMSocket* s = m_socket; 
    617         //              uint32_t uUpStatsPort = GetUserPort(); 
     620//              uint32 uUpStatsPort = GetUserPort(); 
    618621         
    619622                // Extended statistics information based on which client software and which port we sent this data to... 
     
    631634                m_nCurQueueSessionPayloadUp += sentBytesPayload; 
    632635         
    633                 if ( theApp->uploadqueue->CheckForTimeOver ( this ) ) 
    634                 { 
     636        if (theApp->uploadqueue->CheckForTimeOver(this)) { 
    635637                        theApp->uploadqueue->RemoveFromUploadQueue ( this, true ); 
    636638                        SendOutOfPartReqsAndAddToWaitingQueue(); 
    637                 } 
    638                 else 
    639                 { 
     639        } else { 
    640640                        // read blocks from file and put on socket 
    641641                        CreateNextBlockPackage(); 
     
    644644         
    645645        if ( sentBytesCompleteFile + sentBytesPartFile > 0 || 
    646                 m_AvarageUDR_list.size() == 0 || ( curTick - m_AvarageUDR_list.back().timestamp ) > 1*1000 ) 
    647         { 
     646        m_AvarageUDR_list.empty() || (curTick - m_AvarageUDR_list.back().timestamp) > 1*1000) { 
    648647                // Store how much data we've transferred this round, 
    649648                // to be able to calculate average speed later 
    650649                // keep sum of all values in list up to date 
    651                 TransferredData newitem = { (uint32_t) (sentBytesCompleteFile + sentBytesPartFile), curTick}; 
     650        TransferredData newitem = {sentBytesCompleteFile + sentBytesPartFile, curTick}; 
    652651                m_AvarageUDR_list.push_back ( newitem ); 
    653652                m_nSumForAvgUpDataRate += sentBytesCompleteFile + sentBytesPartFile; 
    654653        } 
    655654         
    656         // remove too old values in list 
     655    // remove to old values in list 
    657656        while ( m_AvarageUDR_list.size() > 0 && ( curTick - m_AvarageUDR_list.front().timestamp ) > _average_period*1000 ) 
    658657        { 
     
    663662         
    664663        // Calculate average speed for this slot 
    665         if ( m_AvarageUDR_list.size() > 0 && ( curTick - m_AvarageUDR_list.front().timestamp ) > 0 && GetUpStartTimeDelay() > 2*1000 ) 
    666         { 
    667                 m_nUpDatarate = (uint32_t) 
    668                                 (( m_nSumForAvgUpDataRate * (uint64_t)1000 ) / 
    669                                 (uint64_t) ( curTick-m_AvarageUDR_list.front().timestamp )); 
    670         } 
    671         else 
    672         { 
     664    if ((!m_AvarageUDR_list.empty()) && (curTick - m_AvarageUDR_list.front().timestamp) > 0 && GetUpStartTimeDelay() > 2*1000) { 
     665        m_nUpDatarate = ((uint64)m_nSumForAvgUpDataRate*1000) / (curTick-m_AvarageUDR_list.front().timestamp); 
     666    } else { 
    673667                // not enough values to calculate trustworthy speed. Use -1 to tell this 
    674668                m_nUpDatarate = 0; //-1; 
     
    677671        // Check if it's time to update the display. 
    678672        m_cSendblock++; 
    679         if ( m_cSendblock == 30 ) 
    680         { 
     673        if (m_cSendblock == 30){ 
    681674                m_cSendblock = 0; 
    682675                Notify_UploadCtrlRefreshClient ( this ); 
    683676        } 
    684677         
    685         return (uint32_t) (sentBytesCompleteFile + sentBytesPartFile); 
     678    return sentBytesCompleteFile + sentBytesPartFile; 
    686679        } 
    687680 
     
    698691        //I did some tests with eDonkey also and it seems to work well with them also.. 
    699692         
    700         AddDebugLogLineM(false, logLocalClient, CFormat(wxT("%x (%s --> %s): Local client %x : Sending OP_OUTOFPARTREQS")) % (long) m_socket % m_socket->GetLocal().humanReadable() % m_socket->GetPeer().humanReadable() % (long) this); 
    701          
    702693        // Send this inmediately, don't queue. 
    703         CPacket* pPacket = new CPacket(OP_OUTOFPARTREQS, 0); 
     694        CPacket* pPacket = new CPacket(OP_OUTOFPARTREQS, 0, OP_EDONKEYPROT); 
    704695        theStats::AddUpOverheadFileRequest(pPacket->GetPacketSize()); 
     696        AddDebugLogLineM( false, logLocalClient, wxT("Local Client: OP_OUTOFPARTREQS to ") + GetFullIP() ); 
    705697        SendPacket(pPacket, true, true); 
    706698         
     
    754746                data.WriteHash(file->GetPartHash(i)); 
    755747        } 
    756         CPacket* packet = new CPacket(data); 
    757         packet->SetOpCode(OP_HASHSETANSWER); 
     748        CPacket* packet = new CPacket(data, OP_EDONKEYPROT, OP_HASHSETANSWER);   
    758749        theStats::AddUpOverheadFileRequest(packet->GetPacketSize()); 
     750        AddDebugLogLineM( false, logLocalClient, wxT("Local Client: OP_HASHSETANSWER to ") + GetFullIP()); 
    759751        SendPacket(packet,true,true); 
    760752} 
     
    774766        } 
    775767 
    776         uint16_t nRank = theApp->uploadqueue->GetWaitingPosition(this); 
     768        uint16 nRank = theApp->uploadqueue->GetWaitingPosition(this); 
    777769        if (!nRank) { 
    778770                return; 
     
    783775        // Kry: what are these zero bytes for. are they really correct? 
    784776        // Kry - Well, eMule does like that. I guess they're ok. 
    785         data.WriteUInt32(0);  
    786         data.WriteUInt32(0);  
    787         data.WriteUInt16(0); 
    788  
    789         AddDebugLogLineM(false, logLocalClient, CFormat(wxT("%x (%s --> %s): Local client %x : OP_QUEUERANKING ")) % (long) m_socket % m_socket->GetLocal().humanReadable() % m_socket->GetPeer().humanReadable() % (long) this); 
    790         CPacket* packet = new CPacket(data,OP_EMULEPROT); 
    791         packet->SetOpCode(OP_QUEUERANKING); 
    792          
     777        data.WriteUInt32(0); data.WriteUInt32(0); data.WriteUInt16(0); 
     778        CPacket* packet = new CPacket(data, OP_EMULEPROT, OP_QUEUERANKING); 
    793779        theStats::AddUpOverheadOther(packet->GetPacketSize()); 
     780        AddDebugLogLineM(false, logLocalClient, wxT("Local Client: OP_QUEUERANKING to ") + GetFullIP()); 
    794781        SendPacket(packet,true,true); 
    795782} 
     
    803790        m_bCommentDirty = false; 
    804791 
    805         // We used to limit the comment to 50 before, now we do not anymore. 
    806         const wxString& desc = file->GetFileComment(); 
    807         uint8_t rating = file->GetFileRating(); 
     792        // Truncate to max len. 
     793        wxString desc = file->GetFileComment().Left(MAXFILECOMMENTLEN); 
     794        uint8 rating = file->GetFileRating(); 
    808795         
    809796        if ( file->GetFileRating() == 0 && desc.IsEmpty() ) { 
     
    813800        CMemFile data(256); 
    814801        data.WriteUInt8(rating); 
    815         data.WriteString(desc, GetUnicodeSupport(), 4 /* size it's uint32_t */); 
    816          
    817         AddDebugLogLineM(false, logLocalClient, CFormat(wxT("%x (%s --> %s): Local client %x : OP_FILEDESC")) % (long) m_socket % m_socket->GetLocal().humanReadable() % m_socket->GetPeer().humanReadable() % (long) this);     
    818         CPacket* packet = new CPacket(data,OP_EMULEPROT); 
    819         packet->SetOpCode(OP_FILEDESC); 
     802        data.WriteString(desc, GetUnicodeSupport(), 4 /* size it's uint32 */); 
     803         
     804        CPacket* packet = new CPacket(data, OP_EMULEPROT, OP_FILEDESC); 
    820805        theStats::AddUpOverheadOther(packet->GetPacketSize()); 
     806        AddDebugLogLineM(false, logLocalClient, wxT("Local Client: OP_FILEDESC to ") + GetFullIP());     
    821807        SendPacket(packet,true); 
    822808} 
     
    837823        theApp->clientlist->AddBannedClient( GetTCPDest/*IP*/() ); 
    838824         
    839         AddDebugLogLineM( false, logClient, CFormat(wxT("%x :Client '")) % (long) this + GetUserName() + wxT("' seems to be an aggressive client and is banned from the uploadqueue")); 
     825        AddDebugLogLineM( false, logClient, wxT("Client '") + GetUserName() + wxT("' seems to be an aggressive client and is banned from the uploadqueue")); 
    840826         
    841827        SetUploadState(US_BANNED); 
     
    852838void CUpDownClient::CheckForAggressive() 
    853839{ 
    854         uint32_t cur_time = ::GetTickCount(); 
     840        uint32 cur_time = ::GetTickCount(); 
    855841         
    856842        // First call, initalize 
     
    862848        // Is this an aggressive request? 
    863849        if ( ( cur_time - m_LastFileRequest ) < MIN_REQUESTTIME ) { 
    864                 m_Aggressiveness = (uint16_t) (m_Aggressiveness + 3); 
     850                m_Aggressiveness += 3; 
    865851                 
    866852                // Is the client EVIL?