1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 16:24:02 +00:00

(trunk qt) #3863 "accept info hash in 'Add url...' dialog, not just magnet uris" -- added.

This commit is contained in:
Charles Kerr 2011-01-02 23:42:46 +00:00
parent 7760be2c45
commit 5ccbb741b0
2 changed files with 14 additions and 0 deletions

View file

@ -40,6 +40,11 @@ AddData :: set( const QString& key )
metainfo = file.readAll( );
file.close( );
}
else if( Utils::isHexHashcode( key ) )
{
magnet = QString("magnet:?xt=urn:btih:") + key;
type = MAGNET;
}
else
{
int len;

View file

@ -17,6 +17,8 @@
#include <QObject>
#include <QIcon>
#include <cctype> // isxdigit()
#include "speed.h"
class Utils: public QObject
@ -40,6 +42,13 @@ class Utils: public QObject
static bool isMagnetLink( const QString& s ) { return s.startsWith( "magnet:?" ); }
static bool isHexHashcode( const QString& s )
{
if( s.length() != 40 ) return false;
foreach( QChar ch, s ) if( !isxdigit( ch.toAscii() ) ) return false;
return true;
}
static bool isURL( const QString& s ) { return s.startsWith( "http://" )
|| s.startsWith( "https://" )
|| s.startsWith( "ftp://" ); }