~l3on/ubuntu/saucy/amule-adunanza/upstream-2012.1+2.3.1

« back to all changes in this revision

Viewing changes to src/DownloadListCtrl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-02-18 21:16:23 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100218211623-gptwe60zx1knfkmu
Tags: 2010.1+2.2.6-0ubuntu1
* New upstream release (LP: #524697)
  - Drop manpages_spelling_fixes.diff fixed by upstream
  - Drop cryptopp-reference.diff fixed by upstream
  - Bump Standards-Version no changes required
  - Update install files (amule -> amuleadunanza)
  - debian/rules: amule.xpm -> amuleadunanza.xpm
  - Add README.Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
2
// This file is part of the aMule Project.
3
3
//
4
 
// Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
 
4
// Copyright (c) 2003-2009 aMule Team ( admin@amule.org / http://www.amule.org )
5
5
// Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6
6
//
7
7
// Any parts of this program derived from the xMule, lMule or eMule project,
917
917
                m_menu->AppendSeparator();
918
918
                //-----------------------------------------------------
919
919
                wxMenu* extendedmenu = new wxMenu();
920
 
                extendedmenu->Append(MP_SWAP_A4AF_TO_THIS,
921
 
                        _("Swap every A4AF to this file now"));
922
 
                extendedmenu->AppendCheckItem(MP_SWAP_A4AF_TO_THIS_AUTO,
923
 
                        _("Swap every A4AF to this file (Auto)"));
 
920
                extendedmenu->Append(MP_SWAP_A4AF_TO_THIS, _("Swap every A4AF to this file now"));
 
921
                extendedmenu->AppendCheckItem(MP_SWAP_A4AF_TO_THIS_AUTO, _("Swap every A4AF to this file (Auto)"));
924
922
                //-----------------------------------------------------
925
923
                extendedmenu->AppendSeparator();
926
924
                //-----------------------------------------------------
927
 
                extendedmenu->Append(MP_SWAP_A4AF_TO_ANY_OTHER,
928
 
                        _("Swap every A4AF to any other file now"));
 
925
                extendedmenu->Append(MP_SWAP_A4AF_TO_ANY_OTHER, _("Swap every A4AF to any other file now"));
929
926
                //-----------------------------------------------------
930
 
                m_menu->Append(MP_MENU_EXTD,
931
 
                        _("Extended Options"), extendedmenu);
 
927
                m_menu->Append(MP_MENU_EXTD, _("Extended Options"), extendedmenu);
932
928
                //-----------------------------------------------------
933
929
                m_menu->AppendSeparator();
934
930
                //-----------------------------------------------------
935
931
/* Commented out till RB2 is back 
936
 
                m_menu->Append( MP_RAZORSTATS,
937
 
                        _("Get Razorback 2's stats for this file"));
 
932
                m_menu->Append( MP_RAZORSTATS, _("Get Razorback 2's stats for this file"));
938
933
                //-----------------------------------------------------
939
934
                m_menu->AppendSeparator();
940
935
                //-----------------------------------------------------
946
941
                //-----------------------------------------------------
947
942
                m_menu->AppendSeparator();
948
943
                //-----------------------------------------------------
949
 
                m_menu->Append(MP_GETMAGNETLINK,
950
 
                        _("Copy magnet URI to clipboard"));
951
 
                m_menu->Append(MP_GETED2KLINK,
952
 
                        _("Copy eD2k &link to clipboard"));
953
 
                m_menu->Append(MP_WS,
954
 
                        _("Copy feedback to clipboard"));
 
944
                m_menu->Append(MP_GETMAGNETLINK, _("Copy magnet URI to clipboard"));
 
945
                m_menu->Append(MP_GETED2KLINK, _("Copy eD2k &link to clipboard"));
 
946
                m_menu->Append(MP_WS, _("Copy feedback to clipboard"));
955
947
                //-----------------------------------------------------
956
948
                m_menu->AppendSeparator();
957
949
                //----------------------------------------------------- 
1013
1005
 
1014
1006
                int priority = file->IsAutoDownPriority() ?
1015
1007
                        PR_AUTO : file->GetDownPriority();
1016
 
                
 
1008
 
1017
1009
                priomenu->Check( MP_PRIOHIGH,   priority == PR_HIGH );
1018
1010
                priomenu->Check( MP_PRIONORMAL, priority == PR_NORMAL );
1019
1011
                priomenu->Check( MP_PRIOLOW,    priority == PR_LOW );
1020
1012
                priomenu->Check( MP_PRIOAUTO,   priority == PR_AUTO );
1021
1013
 
1022
1014
                menu->Enable( MP_MENU_EXTD, canPause );
1023
 
        
1024
 
                PopupMenu(m_menu, evt.GetPoint());
1025
 
 
1026
1015
        } else {
1027
1016
                CUpDownClient* client = item->GetSource();
1028
 
                
 
1017
 
1029
1018
                m_menu = new wxMenu(wxT("Clients"));
1030
1019
                m_menu->Append(MP_DETAIL, _("Show &Details"));
1031
1020
                m_menu->Append(MP_ADDFRIEND, client->IsFriend() ? _("Remove from friends") : _("Add to Friends"));
1032
1021
                m_menu->Append(MP_SHOWLIST, _("View Files"));
1033
1022
                m_menu->Append(MP_SENDMESSAGE, _("Send message"));
1034
1023
                m_menu->Append(MP_CHANGE2FILE, _("Swap to this file"));
1035
 
                
 
1024
 
1036
1025
                // Only enable the Swap option for A4AF sources
1037
1026
                m_menu->Enable(MP_CHANGE2FILE, (item->GetType() == A4AF_SOURCE));
1038
1027
                // We need a valid IP if we are to message the client
1039
1028
                m_menu->Enable(MP_SENDMESSAGE, (client->GetIP() != 0));
1040
 
                
 
1029
 
1041
1030
                m_menu->Enable(MP_SHOWLIST, !client->HasDisabledSharedFiles());
1042
 
                
1043
 
                PopupMenu(m_menu, evt.GetPoint());
1044
 
                                        
1045
1031
        }
1046
 
        
 
1032
 
 
1033
        bool autosort = thePrefs::AutoSortDownload(false);
 
1034
        PopupMenu(m_menu, evt.GetPoint());
 
1035
        thePrefs::AutoSortDownload(autosort);
 
1036
 
1047
1037
        delete m_menu;
1048
1038
        m_menu = NULL;
1049
1039
        
1059
1049
        }
1060
1050
 
1061
1051
        CtrlItem_Struct* item = (CtrlItem_Struct*)GetItemData( index );
1062
 
        
 
1052
 
 
1053
        bool autosort = thePrefs::AutoSortDownload(false);
1063
1054
        if ( item->GetType() == FILE_TYPE ) {
1064
1055
                CFileDetailDialog(this, item->GetFile()).ShowModal();
1065
1056
        } else {
1066
1057
                CClientDetailDialog(this, item->GetSource()).ShowModal();
1067
1058
        }
 
1059
        thePrefs::AutoSortDownload(autosort);
1068
1060
}
1069
1061
 
1070
1062
 
1125
1117
        } else {
1126
1118
                dc->SetBackground(*(wxTheBrushList->FindOrCreateBrush(
1127
1119
                        wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX), wxSOLID)));
1128
 
                dc->SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
 
1120
// ADUNANZA BEGIN
 
1121
// Patch da forum.amule.org per bug #0001531
 
1122
#if 0
 
1123
                dc->SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
 
1124
#else
 
1125
#       if wxCHECK_VERSION(2,8,10)
 
1126
                // wsSYS_COLOUR_LISTBOXTEXT introdotta solo con 2.8.10
 
1127
                dc->SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT));
 
1128
#       else
 
1129
                dc->SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
 
1130
#       endif
 
1131
#endif
 
1132
// ADUNANZA END         
1129
1133
        }
1130
1134
 
1131
1135
 
1402
1406
Parte di codice spostata: se ho capito bene 
1403
1407
per prima cosa si vuole avere
1404
1408
text
1405
 
riferita ai sourceconut di Adunanza
 
1409
riferita ai sourcecount di Adunanza
1406
1410
                if ( ncsc ) {
1407
1411
                        text = wxString::Format( wxT("%i/%i" ), sc - ncsc, sc );
1408
1412
                } else {
1483
1487
        }
1484
1488
}
1485
1489
 
 
1490
// ADUNANZA BEGIN
 
1491
// Mr Hyde per Clarensio
 
1492
uint8  CDownloadListCtrl::GetAduMuleSmiley(const CUpDownClient* pClient)
 
1493
{
 
1494
        if (!pClient) return Client_Unknown;
 
1495
 
 
1496
        switch (pClient->GetClientAduType()) {
 
1497
                case ADUNANZA_ICON_ADU:
 
1498
                        switch (pClient->GetClientSoft()) {
 
1499
                                case SO_EMULE: return Client_eMule_AdunanzA_Smiley;
 
1500
                                case SO_AMULE: return Client_aMule_AdunanzA_Smiley;
 
1501
                                default:       return Client_Unknown;
 
1502
                        }
 
1503
                        break; // inutile
 
1504
 
 
1505
                case ADUNANZA_ICON_FW:
 
1506
                        return Client_Fastweb_Smiley;
 
1507
                        break; // inutile
 
1508
 
 
1509
                default:
 
1510
                        switch (pClient->GetClientSoft()) {
 
1511
                                case SO_EMULE: return Client_eMule_Smiley;
 
1512
                                case SO_AMULE: return Client_aMule_Smiley;
 
1513
                                default:       return Client_Unknown;
 
1514
                        }
 
1515
                        break; // inutile
 
1516
        }
 
1517
}
 
1518
// ADUNANZA END
 
1519
 
1486
1520
 
1487
1521
void CDownloadListCtrl::DrawSourceItem(
1488
1522
        wxDC* dc, int nColumn, const wxRect& rect, CtrlItem_Struct* item ) const
1552
1586
#if 0
1553
1587
                                                        clientImage = Client_aMule_Smiley;
1554
1588
#else
1555
 
                                                        clientImage = CamuleDlg::GetAduMuleSmiley(client);
 
1589
                                                        clientImage = CDownloadListCtrl::GetAduMuleSmiley(client);
1556
1590
#endif
1557
1591
// ADUNANZA END
1558
1592
                                                        break;
1572
1606
#if 0
1573
1607
                                                        clientImage = Client_eMule_Smiley;
1574
1608
#else
1575
 
                                                        clientImage = CamuleDlg::GetAduMuleSmiley(client);
 
1609
                                                        clientImage = CDownloadListCtrl::GetAduMuleSmiley(client);
1576
1610
#endif
1577
1611
// ADUNANZA END
1578
1612
                                                        break;
1629
1663
                                // Stefano Picerno: Aggiungo l'immagine giusta a seconda dei flag Adu / Fastweb
1630
1664
                                uint32 client_type = client->GetClientAduType();
1631
1665
                                wxString preUserName = wxString(_(""));
1632
 
                                if (client_type>ADUNANZA_ANY) {
 
1666
                                // if (client_type != ADUNANZA_ICON_NONE) {
 
1667
                                if ((client_type == ADUNANZA_ICON_ADU) || (client_type == ADUNANZA_ICON_FW)) {
 
1668
                                        
1633
1669
                                        if (client->IsFastwebFiber()) // Mr Hyde ADUFLAGS 20080201
1634
1670
                                                m_ImageList.Draw(Client_Fiber_Flag, *dc, point2.x, point.y, wxIMAGELIST_DRAW_TRANSPARENT);
1635
1671
 
1663
1699
// ADUNANZA BEGIN
1664
1700
#if 0                                   
1665
1701
                                        userName << wxT("?");
1666
 
#endif
 
1702
#else
1667
1703
                                        userName << preUserName + wxT("?");
 
1704
#endif
1668
1705
// ADUNANZA END
1669
1706
                                } else {
1670
1707
// ADUNANZA BEGIN
1671
1708
#if 0                                   
1672
1709
                                        userName << client->GetUserName();
1673
 
#endif
 
1710
#else
1674
1711
                                        userName << preUserName + client->GetUserName();
 
1712
#endif
1675
1713
// ADUNANZA END
1676
1714
                                }
1677
1715
                                dc->DrawText(userName, rect.GetX() + 60, rect.GetY());
1903
1941
                result = CmpAny(
1904
1942
                        file1->GetFileName(),
1905
1943
                        file2->GetFileName() );
 
1944
                // Filename shouldn't be equal. If it IS, definitely choose one, so comparison result
 
1945
                // is always defined. (Fallback in MuleListCtrl is wrong for client comparison.)
 
1946
                if (!result) {
 
1947
                        result = CmpAny(file1, file2);
 
1948
                }
1906
1949
                break;
1907
1950
 
1908
1951
        // Sort by size
2126
2169
}
2127
2170
 
2128
2171
 
 
2172
void CDownloadListCtrl::ResetCatParts(uint8 cat)
 
2173
{
 
2174
        // Go through all files
 
2175
        for ( ListItems::iterator it = m_ListItems.begin(); it != m_ListItems.end(); ) {
 
2176
                CtrlItem_Struct* item = it->second; ++it;
 
2177
                
 
2178
                if ( item->GetType() == FILE_TYPE ) {
 
2179
                        CPartFile* file = item->GetFile();
 
2180
                        
 
2181
                        if ( file->GetCategory() == cat ) {
 
2182
                                // Reset the category
 
2183
                                file->SetCategory( 0 );
 
2184
                        } else if ( file->GetCategory() > cat ) {
 
2185
                                // Set to the new position of the original category
 
2186
                                file->SetCategory( file->GetCategory() - 1 );
 
2187
                        }
 
2188
                }
 
2189
        }
 
2190
}
 
2191
 
 
2192
 
2129
2193
void CDownloadListCtrl::ShowFilesCount( int diff )
2130
2194
{
2131
2195
        m_filecount += diff;
2349
2413
                // Remove the .met and see if out video player specifiation uses the magic string
2350
2414
                wxString fileWithoutMet = thePrefs::GetTempDir().JoinPaths(
2351
2415
                        file->GetPartMetFileName().RemoveExt()).GetRaw();
 
2416
                
2352
2417
                if (!command.Replace(wxT("$file"), fileWithoutMet)) {
2353
2418
                        // No magic string, so we just append the filename to the player command
2354
2419
                        // Need to use quotes in case filename contains spaces
2358
2423
                // This is a complete file
2359
2424
                // FIXME: This is probably not going to work if the filenames are mangled ...
2360
2425
                wxString rawFileName = file->GetFullName().GetRaw();
 
2426
 
 
2427
#ifndef __WXMSW__
 
2428
                // We have to escape quote characters in the file name, otherwise arbitrary
 
2429
                // options could be passed to the player.
 
2430
                rawFileName.Replace(QUOTE, wxT("\\") QUOTE);
 
2431
#endif
 
2432
 
2361
2433
                if (!command.Replace(wxT("$file"), rawFileName)) {
2362
2434
                        // No magic string, so we just append the filename to the player command
2363
2435
                        // Need to use quotes in case filename contains spaces