Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more information about each torrent #102

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/gtorrent/Platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace gt
* Creates a directory
* returns the values of the POSIX syscall.
*/
int makeDir(std::string, unsigned);
int makeDir(std::string, mode_t);
/**
* Checks if a directory exists.
*/
Expand Down
230 changes: 215 additions & 15 deletions include/gtorrent/Torrent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ std::string getFileSizeString(boost::int64_t file_size);

namespace libtorrent
{
struct add_torrent_params;
class add_torrent_params;
}

namespace gt
Expand Down Expand Up @@ -56,7 +56,7 @@ namespace gt
}

// Returns formatted active time as string
inline std::string getTextActiveTime()
inline std::string getActiveTimeString()
{
return getTimeString(getActiveTime());
}
Expand All @@ -68,9 +68,16 @@ namespace gt
}

// Returns formatted eta as string
inline std::string getTextEta()
inline std::string getEtaString()
{
return getTimeString(getEta());
if (getHandle().status().progress_ppm == 1000000)
{
return "∞";
}
else
{
return getTimeString(getEta());
}
}

// Returns a vector of bools for each piece, true if we have it, false otherwise
Expand All @@ -82,6 +89,7 @@ namespace gt
return ((float) getHandle().status().progress_ppm / 1000000.0f) * 100.0f;
}


// Returns the current upload rate of the torrent
inline unsigned int getUploadRate()
{
Expand Down Expand Up @@ -175,55 +183,56 @@ namespace gt
void torrentForceRecheck();

// Returns a friendly string for the torrent state
std::string getTextState();
std::string getStateString();

// Returns a friendly string for the current upload rate
inline std::string getTextUploadRate()
inline std::string getUploadRateString()
{
return getRateString(getUploadRate());
}

// Returns a friendly string for the current download rate
inline std::string getTextDownloadRate()
inline std::string getDownloadRateString()
{
return getRateString(getDownloadRate());
}

// Returns a friendly string for the current upload total
inline std::string getTextTotalUploaded()
inline std::string getTotalUploadedString()
{
return getFileSizeString(getTotalUploaded());
}

// Returns a friendly string for the current download total
inline std::string getTextTotalDownloaded()
inline std::string getTotalDownloadedString()
{
return getFileSizeString(getTotalDownloaded());
}

// Returns a friendly string for the total size of files in torrent
inline std::string getTextSize()
inline std::string getSizeString()
{
return getFileSizeString(getSize());
}

// Returns a the total size of files remaining to download in torrent
inline boost::int64_t getRemaining()
{
return getSize() - getTotalDownloaded();
//return getSize() - getTotalDownloaded();
return getHandle().status().total_wanted - getHandle().status().total_wanted_done;
}

// Returns a friendly string for the total size of files remaining to download in torrent
inline std::string getTextRemaining()
inline std::string getRemainingString()
{
return getFileSizeString(getRemaining());
}

// Returns a friendly string for the current ratio
std::string getTextTotalRatio();
std::string getTotalRatioString();

// Returns a friendly string for the current time remaining
inline std::string getTextTimeRemaining()
inline std::string getTimeRemainingString()
{
return getTimeString(getTimeRemaining());
}
Expand Down Expand Up @@ -256,12 +265,203 @@ namespace gt
{
return getHandle().status().name;
}
inline std::string getTorrentFileNameString()
{
//return std::string(getHandle().status().torrent_file);
std::stringstream tfn;
tfn << "torrent-filename.torrent";
return tfn.str();
}

inline std::string getCurrentTrackerString()
{
return getHandle().status().current_tracker;
}

inline std::string getWantedDoneString()
{
//size_type total_wanted_done;
return getFileSizeString(getHandle().status().total_wanted_done);
}
inline std::string getTotalWantedString()
{
//size_type total_wanted;
return getFileSizeString(getHandle().status().total_wanted);
}
inline std::string getAllTimeUploadString()
{
////size_type all_time_upload;
return getFileSizeString(getHandle().status().all_time_upload);
}
inline std::string getAllTimeDownloadString()
{
//size_type all_time_download;
return getFileSizeString(getHandle().status().all_time_download);
}
inline std::string getStorageModeString()
{
std::stringstream sm;
sm << getHandle().status().storage_mode;
return sm.str();
}
inline std::string getProgressString()
{
std::stringstream p;
p << getHandle().status().progress;
return p.str();
}
inline std::string getProgressPpmString()
{
std::stringstream pp;
pp << getHandle().status().progress_ppm;
return pp.str();
}

inline std::string getNumSeedsString()
{
std::stringstream ns;
ns << getHandle().status().num_seeds;
return ns.str();
}
inline std::string getNumPeersString()
{
std::stringstream np;
np << getHandle().status().num_peers;
return np.str();
}
inline std::string getNumCompleteString()
{
std::stringstream nc;
nc << getHandle().status().num_complete;
return nc.str();
}
inline std::string getNumIncompleteString()
{
std::stringstream ni;
ni << getHandle().status().num_incomplete;
return ni.str();
}
inline std::string getListSeedsString()
{
std::stringstream ls;
ls << getHandle().status().list_seeds;
return ls.str();
}
inline std::string getListPeersString()
{
std::stringstream lp;
lp << getHandle().status().list_peers;
return lp.str();
}
inline std::string getConnectCandidatesString()
{
std::stringstream cc;
cc << getHandle().status().connect_candidates;
return cc.str();
}
inline std::string getDistributedCopiesString()
{
std::stringstream dc;
dc << getHandle().status().distributed_copies;
return dc.str();
}

inline std::string getNumUploadsString()
{
std::stringstream nu;
nu << getHandle().status().num_uploads;
return nu.str();
}
inline std::string getNumConnectionsString()
{
std::stringstream nc;
nc << getHandle().status().num_connections;
return nc.str();
}
inline std::string getSeedingTimeString()
{
return getTimeString(getHandle().status().seeding_time);
}
inline std::string getSeedRankString()
{
std::stringstream sr;
sr << getHandle().status().seed_rank;
return sr.str();
}
inline std::string getLastScrapeString()
{
return getTimeString(getHandle().status().last_scrape);
}
inline std::string getSparseRegionsString()
{
std::stringstream sr;
sr << getHandle().status().sparse_regions;
return sr.str();
}
inline std::string getPriorityString()
{
std::stringstream p;
p << getHandle().status().priority;
return p.str();
}
inline std::string getIpFilterAppliesString()
{
std::stringstream ifa;
ifa << getHandle().status().ip_filter_applies;
return ifa.str();
}
inline std::string getPausedString()
{
std::stringstream pa;
pa << getHandle().status().paused;
return pa.str();
}
inline std::string getAutoManagedString()
{
std::stringstream am;
am << getHandle().status().auto_managed;
return am.str();
}
inline std::string getSequentialDownloadString()
{
std::stringstream sd;
sd << getHandle().status().sequential_download;
return sd.str();
}
inline std::string getIsSeedingString()
{
std::stringstream ise;
ise << getHandle().status().is_seeding;
return ise.str();
}
inline std::string getIsFinishedString()
{
std::stringstream ifi;
ifi << getHandle().status().is_finished;
return ifi.str();
}
inline bool hasMetadata()
{
return getHandle().status().has_metadata;
}

inline std::string getHasMetadataString()
{
std::stringstream hm;
hm << getHandle().status().has_metadata;
return hm.str();
}
inline std::string getHasIncomingString()
{
std::stringstream hi;
hi << getHandle().status().has_incoming;
return hi.str();
}
inline std::string getInfoHashString()
{
std::stringstream ih;
ih << getHandle().status().info_hash;
return ih.str();
}
inline std::string getSavePath()
{
return getHandle().status().save_path;
Expand Down
Loading