Changeset 11623


Ignore:
Timestamp:
Jan 2, 2011, 11:42:46 PM (11 years ago)
Author:
charles
Message:

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

Location:
trunk/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/add-data.cc

    r11092 r11623  
    4040        metainfo = file.readAll( );
    4141        file.close( );
     42    }
     43    else if( Utils::isHexHashcode( key ) )
     44    {
     45        magnet = QString("magnet:?xt=urn:btih:") + key;
     46        type = MAGNET;
    4247    }
    4348    else
  • trunk/qt/utils.h

    r11522 r11623  
    1717#include <QObject>
    1818#include <QIcon>
     19
     20#include <cctype> // isxdigit()
    1921
    2022#include "speed.h"
     
    4143        static bool isMagnetLink( const QString& s ) { return s.startsWith( "magnet:?" ); }
    4244
     45        static bool isHexHashcode( const QString& s )
     46        {
     47            if( s.length() != 40 ) return false;
     48            foreach( QChar ch, s ) if( !isxdigit( ch.toAscii() ) ) return false;
     49            return true;
     50        }
     51
    4352        static bool isURL( const QString& s ) { return s.startsWith( "http://" )
    4453                                                    || s.startsWith( "https://" )
Note: See TracChangeset for help on using the changeset viewer.