From d57290f6bd8bb0ab2aba4eb0212e914cea63abef Mon Sep 17 00:00:00 2001 From: Timon Wong Date: Wed, 1 May 2013 13:34:56 +0800 Subject: [PATCH 1/3] MDict: Fix checksum calculating for plain data block --- mdictparser.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mdictparser.cc b/mdictparser.cc index 48f565f9..9ef1f2f2 100644 --- a/mdictparser.cc +++ b/mdictparser.cc @@ -247,13 +247,20 @@ bool MdictParser::parseCompressedBlock( size_t compressedBlockSize, const char * quint32 type; quint32 checksum; type = qFromBigEndian( ( const uchar * ) compressedBlockPtr ); - checksum = qFromBigEndian( ( const uchar * )compressedBlockPtr + sizeof( type ) ); + checksum = qFromBigEndian( ( const uchar * )compressedBlockPtr + sizeof( quint32 ) ); if ( type == 0x00000000 ) { // No compression - checksum >>= 8; - if ( checksum != qFromBigEndian( dataSize - 2 ) ) + checksum &= 0xffff; + quint16 sum = 0; + for ( size_t i = 0; i < dataSize; i++ ) + { + sum += dataPtr[i]; + } + sum += 1; + + if ( checksum != sum ) { qWarning() << "MDict: parseCompressedBlock: plain: checksum not match"; return false; From fc06482c0c50f268e828c7a8a290e7833ca1cd95 Mon Sep 17 00:00:00 2001 From: Timon Wong Date: Wed, 1 May 2013 13:39:27 +0800 Subject: [PATCH 2/3] Add extension for speex encoded sounds --- filetype.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/filetype.cc b/filetype.cc index 779be256..fc9e6a08 100644 --- a/filetype.cc +++ b/filetype.cc @@ -61,7 +61,8 @@ bool isNameOfSound( string const & name ) endsWith( s, ".mpc" ) || endsWith( s, ".wma" ) || endsWith( s, ".wv" ) || - endsWith( s, ".ape" ); + endsWith( s, ".ape" ) || + endsWith( s, ".spx" ); } bool isNameOfPicture( string const & name ) From 66e56b070fb5b86f35f61fb01d0da86729581af7 Mon Sep 17 00:00:00 2001 From: Timon Wong Date: Wed, 1 May 2013 17:31:25 +0800 Subject: [PATCH 3/3] MDict: Increase parser version to deal with plain data block --- mdictparser.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mdictparser.hh b/mdictparser.hh index 2f03be8d..39df86da 100644 --- a/mdictparser.hh +++ b/mdictparser.hh @@ -66,7 +66,7 @@ public: enum { - kParserVersion = 0x000000b + kParserVersion = 0x000000c }; struct RecordIndex