mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
(trunk qt) #3863 "accept info hash in 'Add url...' dialog, not just magnet uris" -- added.
This commit is contained in:
@@ -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://" ); }
|
||||
|
||||
Reference in New Issue
Block a user