case METAINFO: {
tr_info inf;
tr_ctor * ctor = tr_ctorNew( NULL );
- tr_ctorSetMetainfo( ctor, (const uint8_t*)metainfo.constData(), metainfo.size() );
+ tr_ctorSetMetainfo( ctor, (const quint8*)metainfo.constData(), metainfo.size() );
if( tr_torrentParse( ctor, &inf ) == TR_PARSE_OK ) {
ret = QString::fromUtf8( inf.name ); // metainfo is required to be UTF-8
tr_metainfoFree( &inf );
args.append (body); // body
args.append (QStringList ()); // actions - unused for plain passive popups
args.append (QVariantMap ()); // hints - unused atm
- args.append (int32_t (-1)); // use the default timeout period
+ args.append (qint32 (-1)); // use the default timeout period
m.setArguments (args);
QDBusMessage replyMsg = QDBusConnection::sessionBus ().call (m);
//std::cerr << qPrintable (replyMsg.errorName ()) << std::endl;
double sizeWhenDone = 0;
double leftUntilDone = 0;
double available = 0;
- int64_t haveTotal = 0;
- int64_t haveVerified = 0;
- int64_t haveUnverified = 0;
- int64_t verifiedPieces = 0;
+ qint64 haveTotal = 0;
+ qint64 haveVerified = 0;
+ qint64 haveUnverified = 0;
+ qint64 verifiedPieces = 0;
if (torrents.empty ())
{
string = none;
{
haveTotal += t->haveTotal ();
haveUnverified += t->haveUnverified ();
- const uint64_t v = t->haveVerified ();
+ const quint64 v = t->haveVerified ();
haveVerified += v;
if (t->pieceSize ())
verifiedPieces += v / t->pieceSize ();
}
else
{
- uint64_t d = 0;
- uint64_t f = 0;
+ quint64 d = 0;
+ quint64 f = 0;
foreach (const Torrent * t, torrents)
{
d += t->downloadedEver ();
}
else
{
- uint64_t u = 0;
- uint64_t d = 0;
+ quint64 u = 0;
+ quint64 d = 0;
foreach (const Torrent * t, torrents)
{
u += t->uploadedEver ();
else
{
int pieces = 0;
- uint64_t size = 0;
- uint32_t pieceSize = torrents[0]->pieceSize ();
+ quint64 size = 0;
+ quint32 pieceSize = torrents[0]->pieceSize ();
foreach (const Torrent * t, torrents)
{
pieces += t->pieceCount ();
}
void
-FileTreeItem :: getSubtreeWantedSize (uint64_t& have, uint64_t& total) const
+FileTreeItem :: getSubtreeWantedSize (quint64& have, quint64& total) const
{
if (myIsWanted)
{
FileTreeItem :: progress () const
{
double d(0);
- uint64_t have(0), total(0);
+ quint64 have(0), total(0);
getSubtreeWantedSize (have, total);
if (total)
}
else
{
- uint64_t have = 0;
- uint64_t total = 0;
+ quint64 have = 0;
+ quint64 total = 0;
getSubtreeWantedSize (have, total);
str = Formatter::sizeToString (total);
}
FileTreeItem :: update (const QString& name,
bool wanted,
int priority,
- uint64_t haveSize,
+ quint64 haveSize,
bool updateFields)
{
int changed_count = 0;
const QString & filename,
bool wanted,
int priority,
- uint64_t totalSize,
- uint64_t have,
+ quint64 totalSize,
+ quint64 have,
QList<QModelIndex> & rowsAdded,
bool updateFields)
{
virtual ~FileTreeItem();
- FileTreeItem (const QString& name="", int fileIndex=-1, uint64_t size=0):
+ FileTreeItem (const QString& name="", int fileIndex=-1, quint64 size=0):
myFileIndex (fileIndex),
myParent (0),
myName (name),
int row () const;
const QString& name () const { return myName; }
QVariant data (int column, int role) const;
- std::pair<int,int> update (const QString& name, bool want, int priority, uint64_t have, bool updateFields);
+ std::pair<int,int> update (const QString& name, bool want, int priority, quint64 have, bool updateFields);
void twiddleWanted (QSet<int>& fileIds, bool&);
void twiddlePriority (QSet<int>& fileIds, int&);
int fileIndex () const { return myFileIndex; }
- uint64_t totalSize () const { return myTotalSize; }
+ quint64 totalSize () const { return myTotalSize; }
private:
void setSubtreePriority (int priority, QSet<int>& fileIds);
void setSubtreeWanted (bool, QSet<int>& fileIds);
QString priorityString () const;
QString sizeString () const;
- void getSubtreeWantedSize (uint64_t& have, uint64_t& total) const;
+ void getSubtreeWantedSize (quint64& have, quint64& total) const;
double progress () const;
int priority () const;
int isSubtreeWanted () const;
QString myName;
int myPriority;
bool myIsWanted;
- uint64_t myHaveSize;
- const uint64_t myTotalSize;
+ quint64 myHaveSize;
+ const quint64 myTotalSize;
size_t myFirstUnhashedRow;
};
void clear ();
void addFile (int index, const QString& filename,
bool wanted, int priority,
- uint64_t size, uint64_t have,
+ quint64 size, quint64 have,
QList<QModelIndex>& rowsAdded,
bool torrentChanged);
***/
QString
-Formatter :: memToString (int64_t bytes)
+Formatter :: memToString (qint64 bytes)
{
if (bytes < 0)
return tr ("Unknown");
}
QString
-Formatter :: sizeToString (int64_t bytes)
+Formatter :: sizeToString (qint64 bytes)
{
if (bytes < 0)
return tr ("Unknown");
#ifndef QTR_UNITS
#define QTR_UNITS
-#include <inttypes.h> /* uint64_t */
-
#include <QString>
#include <QObject>
#include <QIcon>
public:
- static QString memToString (int64_t bytes);
- static QString sizeToString (int64_t bytes);
+ static QString memToString (qint64 bytes);
+ static QString sizeToString (qint64 bytes);
static QString speedToString (const Speed& speed);
static QString percentToString (double x);
static QString ratioToString (double ratio);
connect (&myTimer, SIGNAL(timeout()), this, SLOT(onTimer()));
- connect (&mySession, SIGNAL(executed(int64_t, const QString&, struct tr_variant*)),
- this, SLOT(onSessionExecuted(int64_t, const QString&, struct tr_variant*)));
+ connect (&mySession, SIGNAL(executed(qint64, const QString&, struct tr_variant*)),
+ this, SLOT(onSessionExecuted(qint64, const QString&, struct tr_variant*)));
setPath (path);
}
void
FreespaceLabel :: onTimer ()
{
- const int64_t tag = mySession.getUniqueTag ();
+ const qint64 tag = mySession.getUniqueTag ();
const QByteArray myPathUtf8 = myPath.toUtf8 ();
myTag = tag;
}
void
-FreespaceLabel :: onSessionExecuted (int64_t tag, const QString& result, struct tr_variant * arguments)
+FreespaceLabel :: onSessionExecuted (qint64 tag, const QString& result, struct tr_variant * arguments)
{
Q_UNUSED (result);
QString str;
// update the label
- int64_t bytes = -1;
+ qint64 bytes = -1;
tr_variantDictFindInt (arguments, TR_KEY_size_bytes, &bytes);
if (bytes >= 0)
setText (tr("%1 free").arg(Formatter::sizeToString (bytes)));
private:
Session& mySession;
- int64_t myTag;
+ qint64 myTag;
QString myPath;
QTimer myTimer;
private slots:
- void onSessionExecuted (int64_t tag, const QString& result, struct tr_variant * arguments);
+ void onSessionExecuted (qint64 tag, const QString& result, struct tr_variant * arguments);
void onTimer ();
};
TrMainWindow :: trayActivated (QSystemTrayIcon::ActivationReason reason)
{
if ((reason == QSystemTrayIcon::Trigger) ||
- (reason == QSystemTrayIcon::DoubleClick)
+ (reason == QSystemTrayIcon::DoubleClick))
{
if (isMinimized ())
toggleWindows (true);
***/
void
-FileAdded :: executed (int64_t tag, const QString& result, struct tr_variant * arguments)
+FileAdded :: executed (qint64 tag, const QString& result, struct tr_variant * arguments)
{
Q_UNUSED (arguments);
break;
case AddData::METAINFO:
- tr_ctorSetMetainfo (ctor, (const uint8_t*)myAdd.metainfo.constData (), myAdd.metainfo.size ());
+ tr_ctorSetMetainfo (ctor, (const quint8*)myAdd.metainfo.constData (), myAdd.metainfo.size ());
break;
default:
{
// rpc spec section 3.4 "adding a torrent"
- const int64_t tag = mySession.getUniqueTag ();
+ const qint64 tag = mySession.getUniqueTag ();
tr_variant top;
tr_variantInitDict (&top, 3);
tr_variantDictAddStr (&top, TR_KEY_method, "torrent-add");
FileAdded * fileAdded = new FileAdded (tag, myAdd.readableName ());
if (myTrashCheck->isChecked () && (myAdd.type==AddData::FILENAME))
fileAdded->setFileToDelete (myAdd.filename);
- connect (&mySession, SIGNAL (executed (int64_t,const QString&, struct tr_variant*)),
- fileAdded, SLOT (executed (int64_t,const QString&, struct tr_variant*)));
+ connect (&mySession, SIGNAL (executed (qint64,const QString&, struct tr_variant*)),
+ fileAdded, SLOT (executed (qint64,const QString&, struct tr_variant*)));
mySession.exec (&top);
namespace
{
- uint64_t getPieceSize (const tr_info * info, tr_piece_index_t pieceIndex)
+ quint64 getPieceSize (const tr_info * info, tr_piece_index_t pieceIndex)
{
if (pieceIndex != info->pieceCount - 1)
return info->pieceSize;
myVerifyFile.open (QIODevice::ReadOnly);
}
- int64_t leftInPiece = getPieceSize (&myInfo, myVerifyPieceIndex) - myVerifyPiecePos;
- int64_t leftInFile = file->length - myVerifyFilePos;
- int64_t bytesThisPass = std::min (leftInFile, leftInPiece);
- bytesThisPass = std::min (bytesThisPass, (int64_t)sizeof (myVerifyBuf));
+ qint64 leftInPiece = getPieceSize (&myInfo, myVerifyPieceIndex) - myVerifyPiecePos;
+ qint64 leftInFile = file->length - myVerifyFilePos;
+ qint64 bytesThisPass = std::min (leftInFile, leftInPiece);
+ bytesThisPass = std::min (bytesThisPass, (qint64)sizeof (myVerifyBuf));
if (myVerifyFile.isOpen () && myVerifyFile.seek (myVerifyFilePos))
{
- int64_t numRead = myVerifyFile.read (myVerifyBuf, bytesThisPass);
+ qint64 numRead = myVerifyFile.read (myVerifyBuf, bytesThisPass);
if (numRead == bytesThisPass)
myVerifyHash.addData (myVerifyBuf, numRead);
}
bool done = myVerifyPieceIndex >= myInfo.pieceCount;
if (done)
{
- uint64_t have = 0;
+ quint64 have = 0;
foreach (const TrFile& f, myFiles)
have += f.have;
void setFileToDelete (const QString& file) { myDelFile = file; }
public slots:
- void executed (int64_t tag, const QString& result, struct tr_variant * arguments);
+ void executed (qint64 tag, const QString& result, struct tr_variant * arguments);
private:
- const int64_t myTag;
+ const qint64 myTag;
QString myName;
QString myDelFile;
};
QTimer myVerifyTimer;
char myVerifyBuf[2048*4];
QFile myVerifyFile;
- uint64_t myVerifyFilePos;
+ quint64 myVerifyFilePos;
int myVerifyFileIndex;
- uint32_t myVerifyPieceIndex;
- uint32_t myVerifyPiecePos;
+ quint32 myVerifyPieceIndex;
+ quint32 myVerifyPiecePos;
void clearVerify ();
QVector<bool> myVerifyFlags;
QCryptographicHash myVerifyHash;
- typedef QMap<uint32_t,int32_t> mybins_t;
+ typedef QMap<quint32,qint32> mybins_t;
mybins_t myVerifyBins;
QTimer myEditTimer;
};
{
double d;
bool boolVal;
- int64_t intVal;
+ qint64 intVal;
const char * str;
size_t strLen;
tr_variant * b (tr_variantDictFind (&top, myItems[i].key));
const int err (tr_variantFromJson (&top, json, jsonLength));
if (!err)
{
- int64_t tag = -1;
+ qint64 tag = -1;
const char * result = NULL;
tr_variant * args = NULL;
break;
case TAG_BLOCKLIST_UPDATE: {
- int64_t intVal = 0;
+ qint64 intVal = 0;
if (tr_variantDictFindDict (&top, TR_KEY_arguments, &args))
if (tr_variantDictFindInt (args, TR_KEY_blocklist_size, &intVal))
setBlocklistSize (intVal);
case TAG_RENAME_PATH:
{
- int64_t id = 0;
+ qint64 id = 0;
const char * result = 0;
if (tr_variantDictFindStr (&top, TR_KEY_result, &result, 0) && strcmp (result, "success"))
{
void
Session :: updateStats (tr_variant * d, struct tr_session_stats * stats)
{
- int64_t i;
+ qint64 i;
if (tr_variantDictFindInt (d, TR_KEY_uploadedBytes, &i))
stats->uploadedBytes = i;
void
Session :: updateInfo (tr_variant * d)
{
- int64_t i;
+ qint64 i;
const char * str;
disconnect (&myPrefs, SIGNAL (changed (int)), this, SLOT (updatePref (int)));
{
case QVariant :: Int:
{
- int64_t val;
+ qint64 val;
if (tr_variantGetInt (b, &val))
myPrefs.set (i, (int)val);
break;
}
void
-Session :: setBlocklistSize (int64_t i)
+Session :: setBlocklistSize (qint64 i)
{
myBlocklistSize = i;
const QString& sessionVersion () const { return mySessionVersion; }
public:
- int64_t blocklistSize () const { return myBlocklistSize; }
- void setBlocklistSize (int64_t i);
+ qint64 blocklistSize () const { return myBlocklistSize; }
+ void setBlocklistSize (qint64 i);
void updateBlocklist ();
void portTest ();
void copyMagnetLinkToClipboard (int torrentId);
void exec (const struct tr_variant * request);
public:
- int64_t getUniqueTag () { return nextUniqueTag++; }
+ qint64 getUniqueTag () { return nextUniqueTag++; }
private:
void sessionSet (const tr_quark key, const QVariant& variant);
signals:
void responseReceived (const QByteArray& json);
- void executed (int64_t tag, const QString& result, struct tr_variant * arguments);
+ void executed (qint64 tag, const QString& result, struct tr_variant * arguments);
void sourceChanged ();
void portTested (bool isOpen);
void statsUpdated ();
void httpAuthenticationRequired ();
private:
- int64_t nextUniqueTag;
- int64_t myBlocklistSize;
+ qint64 nextUniqueTag;
+ qint64 myBlocklistSize;
Prefs& myPrefs;
tr_session * mySession;
QString myConfigDir;
const bool isMagnet( !tor.hasMetadata( ) );
const bool isDone( tor.isDone( ) );
const bool isSeed( tor.isSeed( ) );
- const uint64_t haveTotal( tor.haveTotal( ) );
+ const quint64 haveTotal( tor.haveTotal( ) );
QString str;
double seedRatio;
const bool hasSeedRatio( tor.getSeedRatio( seedRatio ) );
int i = 0;
tr_variant * child;
while(( child = tr_variantListChild( torrents, i++ ))) {
- int64_t intVal;
+ qint64 intVal;
if( tr_variantGetInt( child, &intVal ) )
removeTorrent( intVal );
}
tr_variant * child;
while(( child = tr_variantListChild( torrents, i++ )))
{
- int64_t id;
+ qint64 id;
if( tr_variantDictFindInt( child, TR_KEY_id, &id ) )
{
newIds.insert( id );
static int key_to_property_index[TR_N_KEYS];
bool changed = false;
const bool was_seed = isSeed ();
- const uint64_t old_verified_size = haveVerified ();
+ const quint64 old_verified_size = haveVerified ();
if (!lookup_initialized)
{
{
case QVariant :: Int:
{
- int64_t val;
+ qint64 val;
if (tr_variantGetInt (child, &val))
changed |= setInt (property_index, val);
break;
}
case QVariant :: ULongLong:
{
- int64_t val;
+ qint64 val;
if (tr_variantGetInt (child, &val))
changed |= setSize (property_index, val);
break;
}
case QVariant :: DateTime:
{
- int64_t val;
+ qint64 val;
if (tr_variantGetInt (child, &val) && val)
changed |= setDateTime (property_index, QDateTime :: fromTime_t(val));
break;
if (tr_variantDictFindList (d, TR_KEY_files, &files))
{
const char * str;
- int64_t intVal;
+ qint64 intVal;
int i = 0;
tr_variant * child;
for (int i=0; i<n && i<myFiles.size(); ++i)
{
- int64_t intVal;
+ qint64 intVal;
bool boolVal;
tr_variant * child = tr_variantListChild (files, i);
TrFile& file (myFiles[i]);
while ((child = tr_variantListChild (trackerStats, childNum++)))
{
bool b;
- int64_t i;
+ qint64 i;
size_t len;
const char * str;
TrackerStat trackerStat;
{
double d;
bool b;
- int64_t i;
+ qint64 i;
size_t len;
const char * str;
Peer peer;
int index;
int priority;
QString filename;
- uint64_t size;
- uint64_t have;
+ quint64 size;
+ quint64 have;
};
typedef QList<TrFile> FileList;
bool isSeed( ) const { return haveVerified() >= totalSize(); }
bool isPrivate( ) const { return getBool( IS_PRIVATE ); }
bool getSeedRatio( double& setme ) const;
- uint64_t haveVerified( ) const { return getSize( HAVE_VERIFIED ); }
- uint64_t haveUnverified( ) const { return getSize( HAVE_UNCHECKED ); }
- uint64_t desiredAvailable( ) const { return getSize( DESIRED_AVAILABLE ); }
- uint64_t haveTotal( ) const { return haveVerified( ) + haveUnverified(); }
- uint64_t totalSize( ) const { return getSize( TOTAL_SIZE ); }
- uint64_t sizeWhenDone( ) const { return getSize( SIZE_WHEN_DONE ); }
- uint64_t leftUntilDone( ) const { return getSize( LEFT_UNTIL_DONE ); }
- uint64_t pieceSize( ) const { return getSize( PIECE_SIZE ); }
+ quint64 haveVerified( ) const { return getSize( HAVE_VERIFIED ); }
+ quint64 haveUnverified( ) const { return getSize( HAVE_UNCHECKED ); }
+ quint64 desiredAvailable( ) const { return getSize( DESIRED_AVAILABLE ); }
+ quint64 haveTotal( ) const { return haveVerified( ) + haveUnverified(); }
+ quint64 totalSize( ) const { return getSize( TOTAL_SIZE ); }
+ quint64 sizeWhenDone( ) const { return getSize( SIZE_WHEN_DONE ); }
+ quint64 leftUntilDone( ) const { return getSize( LEFT_UNTIL_DONE ); }
+ quint64 pieceSize( ) const { return getSize( PIECE_SIZE ); }
bool hasMetadata( ) const { return getDouble( METADATA_PERCENT_DONE ) >= 1.0; }
bool isMagnet( ) const { return magnetTorrent; }
int pieceCount( ) const { return getInt( PIECE_COUNT ); }
double percentComplete( ) const { return haveTotal() / (double)totalSize(); }
double percentDone( ) const { return getDouble( PERCENT_DONE ); }
double metadataPercentDone( ) const { return getDouble( METADATA_PERCENT_DONE ); }
- uint64_t downloadedEver( ) const { return getSize( DOWNLOADED_EVER ); }
- uint64_t uploadedEver( ) const { return getSize( UPLOADED_EVER ); }
- uint64_t failedEver( ) const { return getSize( FAILED_EVER ); }
+ quint64 downloadedEver( ) const { return getSize( DOWNLOADED_EVER ); }
+ quint64 uploadedEver( ) const { return getSize( UPLOADED_EVER ); }
+ quint64 failedEver( ) const { return getSize( FAILED_EVER ); }
int compareTracker( const Torrent& ) const;
int compareSeedRatio( const Torrent& ) const;
int compareRatio( const Torrent& ) const;