1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

(trunk) fix a documentation error in the RPC spec. lastAnnounceResult is a string, not an int

This commit is contained in:
Charles Kerr 2010-08-01 14:51:28 +00:00
parent ef8ffe3512
commit 040bc734f8
6 changed files with 47 additions and 5 deletions

View file

@ -276,7 +276,7 @@
| id | number | tr_tracker_stat
| isBackup | boolean | tr_tracker_stat
| lastAnnouncePeerCount | number | tr_tracker_stat
| lastAnnounceResult | number | tr_tracker_stat
| lastAnnounceResult | string | tr_tracker_stat
| lastAnnounceStartTime | number | tr_tracker_stat
| lastAnnounceSucceeded | boolean | tr_tracker_stat
| lastAnnounceTime | number | tr_tracker_stat

View file

@ -15,6 +15,7 @@
#include <iostream>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDBusError>
#include <QDBusMessage>
#include <QDialogButtonBox>
@ -167,6 +168,7 @@ MyApp :: MyApp( int& argc, char ** argv ):
connect( mySession, SIGNAL(sourceChanged()), this, SLOT(onSessionSourceChanged()) );
// when the model sees a torrent for the first time, ask the session for full info on it
connect( myModel, SIGNAL(torrentsAdded(QSet<int>)), mySession, SLOT(initTorrents(QSet<int>)) );
connect( myModel, SIGNAL(torrentsAdded(QSet<int>)), this, SLOT(torrentsAdded(QSet<int>)) );
mySession->initTorrents( );
mySession->refreshSessionStats( );
@ -244,6 +246,13 @@ MyApp :: MyApp( int& argc, char ** argv ):
std::cerr << qPrintable(bus.lastError().message()) << std::endl;
}
void
MyApp :: torrentsAdded( QSet<int> torrents )
{
myAddedTorrents += torrents;
std::cerr << "added count is " << myAddedTorrents.size() << std::endl;
}
void
MyApp :: consentGiven( )
{
@ -354,12 +363,40 @@ MyApp :: addTorrent( const QString& key )
raise( );
}
/***
****
***/
void
MyApp :: raise( )
{
QApplication :: alert ( myWindow );
}
bool
MyApp :: notify( const QString& title, const QString& body, int timeout_msec ) const
{
const QString dbusServiceName = "org.freedesktop.Notifications";
const QString dbusInterfaceName = "org.freedesktop.Notifications";
const QString dbusPath = "/org/freedesktop/Notifications";
QDBusMessage m = QDBusMessage::createMethodCall(dbusServiceName, dbusPath, dbusInterfaceName, "Notify");
QList<QVariant> args;
args.append( "Transmission" ); // app_name
args.append( 0U ); // replaces_id
args.append( "transmission" ); // icon
args.append( title ); // summary
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
m.setArguments( args );
QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m);
//std::cerr << qPrintable(replyMsg.errorName()) << std::endl;
//std::cerr << qPrintable(replyMsg.errorMessage()) << std::endl;
return (replyMsg.type() == QDBusMessage::ReplyMessage) && !replyMsg.arguments().isEmpty();
}
/***
****
***/
@ -402,5 +439,6 @@ main( int argc, char * argv[] )
tr_optind = 1;
MyApp app( argc, argv );
app.notify( "hello world", "this is a test" );
return app.exec( );
}

View file

@ -14,6 +14,7 @@
#define QTR_APP_H
#include <QApplication>
#include <QSet>
#include <QTimer>
#include "favicon.h"
@ -33,6 +34,7 @@ class MyApp: public QApplication
public:
void raise( );
bool notify( const QString& title, const QString& body, int timeout_msec=-1 ) const;
public:
Favicons favicons;
@ -47,12 +49,14 @@ class MyApp: public QApplication
QTimer myStatsTimer;
QTimer mySessionTimer;
time_t myLastFullUpdateTime;
QSet<int> myAddedTorrents;
private slots:
void consentGiven( );
void onSessionSourceChanged( );
void refreshPref( int key );
void refreshTorrents( );
void torrentsAdded( QSet<int> );
public slots:
void addTorrent( const QString& );

View file

@ -586,8 +586,8 @@ Torrent :: update( tr_benc * d )
trackerStat.isBackup = b;
if( tr_bencDictFindInt( child, "lastAnnouncePeerCount", &i ) )
trackerStat.lastAnnouncePeerCount = i;
if( tr_bencDictFindInt( child, "lastAnnounceResult", &i ) )
trackerStat.lastAnnounceResult = i;
if( tr_bencDictFindStr( child, "lastAnnounceResult", &str ) )
trackerStat.lastAnnounceResult = str;
if( tr_bencDictFindInt( child, "lastAnnounceStartTime", &i ) )
trackerStat.lastAnnounceStartTime = i;
if( tr_bencDictFindBool( child, "lastAnnounceSucceeded", &b ) )

View file

@ -71,7 +71,7 @@ struct TrackerStat
int id;
bool isBackup;
int lastAnnouncePeerCount;
int lastAnnounceResult;
QString lastAnnounceResult;
int lastAnnounceStartTime;
bool lastAnnounceSucceeded;
int lastAnnounceTime;

View file

@ -184,7 +184,7 @@ TrackerDelegate :: getText( const TrackerInfo& inf ) const
{
str += tr( "Got an error %1\"%2\"%3 %4 ago" )
.arg( err_markup_begin )
.arg( tstr )
.arg( inf.st.lastAnnounceResult )
.arg( err_markup_end )
.arg( tstr );
}