mirror of
https://github.com/transmission/transmission
synced 2024-12-24 00:34:04 +00:00
(trunk qt) #3863 "accept info hash in 'Add url...' dialog, not just magnet uris" -- added.
This commit is contained in:
parent
7760be2c45
commit
5ccbb741b0
2 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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://" ); }
|
||||
|
|
Loading…
Reference in a new issue