This file is indexed.

/usr/include/eiskaltdcpp/dcpp/UploadManager.h is in libeiskaltdcpp-dev 2.2.9-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 * Copyright (C) 2001-2012 Jacek Sieka, arnetheduck on gmail point com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#pragma once

#include "forward.h"
#include "UserConnectionListener.h"
#include "Singleton.h"
#include "UploadManagerListener.h"
#include "Client.h"
#include "ClientManagerListener.h"
#include "MerkleTree.h"
#include "User.h"
#include "Util.h"
#include "TimerManager.h"
#include "Speaker.h"
#include "PerFolderLimit.h"
#include "SettingsManager.h"

namespace dcpp {

class UploadManager : private ClientManagerListener, private UserConnectionListener, public Speaker<UploadManagerListener>, private TimerManagerListener, public Singleton<UploadManager>
{
public:
    /** @return Number of uploads. */
    size_t getUploadCount() { Lock l(cs); return uploads.size(); }

    /**
     * @remarks This is only used in the tray icons. Could be used in
     * MainFrame too.
     *
     * @return Running average download speed in Bytes/s
     */
    int64_t getRunningAverage();
    uint8_t getSlots() const { return (uint8_t) (SETTING(SLOTS)* Client::getTotalCounts());}
    /** @return Number of free slots. */
    int getFreeSlots() { return max((SETTING(SLOTS) - running), 0); }

    /** @internal */
    int getFreeExtraSlots() { return max(3 - getExtra(), 0); }

    /** @param aUser Reserve an upload slot for this user and connect. */
    void reserveSlot(const HintedUser& aUser);

    /** */
    void reloadRestrictions();

    typedef set<string> FileSet;
    typedef unordered_map<UserPtr, FileSet, User::Hash> FilesMap;
    void clearUserFiles(const UserPtr&);
    HintedUserList getWaitingUsers() const;
    const FileSet& getWaitingUserFiles(const UserPtr&);

    /** @internal */
    void addConnection(UserConnectionPtr conn);

    void notifyQueuedUsers();
    void setRunning(int _running) { running = _running; notifyQueuedUsers(); }

    //GETSET(int, running, Running);
    GETSET(uint8_t, extraPartial, ExtraPartial);
    GETSET(uint8_t, extra, Extra);
    GETSET(uint64_t, lastGrant, LastGrant);

    void updateLimits() {limits.RenewList(NULL);}
private:
    int running;
    UploadList uploads;
    mutable CriticalSection cs;

    typedef unordered_set<UserPtr, User::Hash> SlotSet;
    typedef SlotSet::iterator SlotIter;
    SlotSet reservedSlots;
    CPerfolderLimit limits;
    int lastFreeSlots; /// amount of free slots at the previous minute

    typedef pair<HintedUser, uint64_t> WaitingUser;
    typedef list<WaitingUser> WaitingUserList;

    struct WaitingUserFresh {
        bool operator()(const WaitingUser& wu) { return wu.second > GET_TICK() - 5*60*1000; }
    };

    //functions for manipulating waitingFiles and waitingUsers
    WaitingUserList waitingUsers;       //this one merely lists the users waiting for slots
    FilesMap waitingFiles;      //set of files which this user has asked for
    void addFailedUpload(const UserConnection& source, string filename);

    friend class Singleton<UploadManager>;
    UploadManager() noexcept;
    virtual ~UploadManager();

    bool getAutoSlot();
    bool hasUpload ( UserConnection& aSource );
    void removeConnection(UserConnection* aConn);
    void removeUpload(Upload* aUpload);

    // ClientManagerListener
    virtual void on(ClientManagerListener::UserDisconnected, const UserPtr& aUser) noexcept;

    // TimerManagerListener
    virtual void on(Second, uint64_t aTick) noexcept;
    virtual void on(Minute, uint64_t aTick) noexcept;

    // UserConnectionListener
    virtual void on(BytesSent, UserConnection*, size_t, size_t) noexcept;
    virtual void on(Failed, UserConnection*, const string&) noexcept;
    virtual void on(Get, UserConnection*, const string&, int64_t) noexcept;
    virtual void on(Send, UserConnection*) noexcept;
    virtual void on(GetListLength, UserConnection* conn) noexcept;
    virtual void on(TransmitDone, UserConnection*) noexcept;

    virtual void on(AdcCommand::GET, UserConnection*, const AdcCommand&) noexcept;
    virtual void on(AdcCommand::GFI, UserConnection*, const AdcCommand&) noexcept;

    bool prepareFile(UserConnection& aSource, const string& aType, const string& aFile, int64_t aResume, int64_t aBytes, bool listRecursive = false);
};

} // namespace dcpp