Expose struct DownloadHandle interface to public API directly

libaria2
Tatsuhiro Tsujikawa 2013-05-01 11:58:25 +09:00
parent 8f659f49ec
commit 5e64d4c9a9
3 changed files with 16 additions and 97 deletions

View File

@ -386,69 +386,4 @@ void deleteDownloadHandle(DownloadHandle* dh)
delete dh;
}
DOWNLOAD_STATUS downloadGetStatus(DownloadHandle* dh)
{
return dh->getStatus();
}
int64_t downloadGetTotalLength(DownloadHandle* dh)
{
return dh->getTotalLength();
}
int64_t downloadGetCompletedLength(DownloadHandle* dh)
{
return dh->getCompletedLength();
}
int64_t downloadGetUploadLength(DownloadHandle* dh)
{
return dh->getUploadLength();
}
std::string downloadGetBitfield(DownloadHandle* dh)
{
return dh->getBitfield();
}
int downloadGetDownloadSpeed(DownloadHandle* dh)
{
return dh->getDownloadSpeed();
}
int downloadGetUploadSpeed(DownloadHandle* dh)
{
return dh->getUploadSpeed();
}
size_t downloadGetNumPieces(DownloadHandle* dh)
{
return dh->getNumPieces();
}
int downloadGetConnections(DownloadHandle* dh)
{
return dh->getConnections();
}
int downloadGetErrorCode(DownloadHandle* dh)
{
return dh->getErrorCode();
}
const std::vector<A2Gid>& downloadGetFollowedBy(DownloadHandle* dh)
{
return dh->getFollowedBy();
}
A2Gid downloadGetBelongsTo(DownloadHandle* dh)
{
return dh->getBelongsTo();
}
const std::string& downloadGetDir(DownloadHandle* dh)
{
return dh->getDir();
}
} // namespace aria2

View File

@ -50,23 +50,6 @@ struct Session {
SharedHandle<Context> context;
};
struct DownloadHandle {
virtual ~DownloadHandle() {}
virtual DOWNLOAD_STATUS getStatus() = 0;
virtual int64_t getTotalLength() = 0;
virtual int64_t getCompletedLength() = 0;
virtual int64_t getUploadLength() = 0;
virtual std::string getBitfield() = 0;
virtual int getDownloadSpeed() = 0;
virtual int getUploadSpeed() = 0;
virtual size_t getNumPieces() = 0;
virtual int getConnections() = 0;
virtual int getErrorCode() = 0;
virtual const std::vector<A2Gid>& getFollowedBy() = 0;
virtual A2Gid getBelongsTo() = 0;
virtual const std::string& getDir() = 0;
};
} // namespace aria2
#endif // ARIA2_API_H

View File

@ -143,7 +143,22 @@ enum DOWNLOAD_STATUS {
DOWNLOAD_REMOVED
};
struct DownloadHandle;
struct DownloadHandle {
virtual ~DownloadHandle() {}
virtual DOWNLOAD_STATUS getStatus() = 0;
virtual int64_t getTotalLength() = 0;
virtual int64_t getCompletedLength() = 0;
virtual int64_t getUploadLength() = 0;
virtual std::string getBitfield() = 0;
virtual int getDownloadSpeed() = 0;
virtual int getUploadSpeed() = 0;
virtual size_t getNumPieces() = 0;
virtual int getConnections() = 0;
virtual int getErrorCode() = 0;
virtual const std::vector<A2Gid>& getFollowedBy() = 0;
virtual A2Gid getBelongsTo() = 0;
virtual const std::string& getDir() = 0;
};
// Returns handle for the download denoted by the |gid|. The caller
// can retrieve various information of the download via returned
@ -156,20 +171,6 @@ DownloadHandle* getDownloadHandle(Session* session, const A2Gid& gid);
// Deallocates the |dh|. Calling this function with NULL is safe.
void deleteDownloadHandle(DownloadHandle* dh);
DOWNLOAD_STATUS downloadGetStatus(DownloadHandle* dh);
int64_t downloadGetTotalLength(DownloadHandle* dh);
int64_t downloadGetCompletedLength(DownloadHandle* dh);
int64_t downloadGetUploadLength(DownloadHandle* dh);
std::string downloadGetBitfield(DownloadHandle* dh);
int downloadGetDownloadSpeed(DownloadHandle* dh);
int downloadGetUploadSpeed(DownloadHandle* dh);
size_t downloadGetNumPieces(DownloadHandle* dh);
int downloadGetConnections(DownloadHandle* dh);
int downloadGetErrorCode(DownloadHandle* dh);
const std::vector<A2Gid>& downloadGetFollowedBy(DownloadHandle* dh);
A2Gid downloadGetBelongsTo(DownloadHandle* dh);
const std::string& downloadGetDir(DownloadHandle* dh);
} // namespace aria2
#endif // ARIA2_H