mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Compare commits
4 commits
0680edd1e9
...
5b70a7e081
Author | SHA1 | Date | |
---|---|---|---|
5b70a7e081 | |||
9a544c5715 | |||
2aa97ee557 | |||
76aaed116b |
|
@ -18,3 +18,6 @@ d15081e723756eef053550dc9e06e31d7828dec3
|
|||
|
||||
# remove gd::toWString
|
||||
c8af0450f1f7f8188004db96e3f53e7e33e2ccad
|
||||
|
||||
# remove gddebug.hh and associated functions
|
||||
76aaed116bdc3aeb53fd61553aedb877baf9b510
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "article_maker.hh"
|
||||
#include "config.hh"
|
||||
#include "folding.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "globalbroadcaster.hh"
|
||||
#include "globalregex.hh"
|
||||
#include "htmlescape.hh"
|
||||
|
@ -540,7 +539,7 @@ void ArticleRequest::altSearchFinished()
|
|||
bodyRequests.push_back( r );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "getArticle request error (%s) in \"%s\"\n", e.what(), activeDict->getName().c_str() );
|
||||
qWarning( "getArticle request error (%s) in \"%s\"", e.what(), activeDict->getName().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -618,7 +617,7 @@ void ArticleRequest::bodyFinished()
|
|||
return;
|
||||
}
|
||||
|
||||
GD_DPRINTF( "some body finished" );
|
||||
qDebug( "some body finished" );
|
||||
|
||||
bool wasUpdated = false;
|
||||
|
||||
|
@ -628,7 +627,7 @@ void ArticleRequest::bodyFinished()
|
|||
if ( bodyRequests.front()->isFinished() ) {
|
||||
// Good
|
||||
|
||||
GD_DPRINTF( "one finished." );
|
||||
qDebug( "one finished." );
|
||||
|
||||
Dictionary::DataRequest & req = *bodyRequests.front();
|
||||
|
||||
|
@ -718,7 +717,7 @@ void ArticleRequest::bodyFinished()
|
|||
}
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "getDataSlice error: %s\n", e.what() );
|
||||
qWarning( "getDataSlice error: %s", e.what() );
|
||||
}
|
||||
|
||||
wasUpdated = true;
|
||||
|
@ -728,12 +727,12 @@ void ArticleRequest::bodyFinished()
|
|||
//signal finished dictionary for pronounciation
|
||||
GlobalBroadcaster::instance()->pronounce_engine.finishDictionary( dictId );
|
||||
}
|
||||
GD_DPRINTF( "erasing.." );
|
||||
qDebug( "erasing.." );
|
||||
bodyRequests.pop_front();
|
||||
GD_DPRINTF( "erase done.." );
|
||||
qDebug( "erase done.." );
|
||||
}
|
||||
else {
|
||||
GD_DPRINTF( "one not finished." );
|
||||
qDebug( "one not finished." );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -976,7 +975,7 @@ void ArticleRequest::compoundSearchNextStep( bool lastSearchSucceeded )
|
|||
|
||||
// Look it up
|
||||
|
||||
// GD_DPRINTF( "Looking up %s\n", qPrintable( currentSplittedWordCompound ) );
|
||||
// qDebug( "Looking up %s", qPrintable( currentSplittedWordCompound ) );
|
||||
|
||||
stemmedWordFinder->expressionMatch( currentSplittedWordCompound,
|
||||
activeDicts,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <stdint.h>
|
||||
#include <QUrl>
|
||||
#include "article_netmgr.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "utils.hh"
|
||||
#include <QNetworkAccessManager>
|
||||
#include "globalbroadcaster.hh"
|
||||
|
@ -93,7 +92,7 @@ QNetworkReply * ArticleNetworkAccessManager::getArticleReply( QNetworkRequest co
|
|||
//if not external url,can be blocked from here. no need to continue execute the following code.
|
||||
//such as bres://upload.wikimedia.... etc .
|
||||
if ( !Utils::isExternalLink( url ) ) {
|
||||
gdWarning( R"(Blocking element "%s" as built-in link )", req.url().toEncoded().data() );
|
||||
qWarning( R"(Blocking element "%s" as built-in link )", req.url().toEncoded().data() );
|
||||
return new BlockedNetworkReply( this );
|
||||
}
|
||||
|
||||
|
@ -108,7 +107,7 @@ QNetworkReply * ArticleNetworkAccessManager::getArticleReply( QNetworkRequest co
|
|||
if ( !url.host().endsWith( refererUrl.host() )
|
||||
&& Utils::Url::getHostBaseFromUrl( url ) != Utils::Url::getHostBaseFromUrl( refererUrl )
|
||||
&& !url.scheme().startsWith( "data" ) ) {
|
||||
gdWarning( R"(Blocking element "%s" due to not same domain)", url.toEncoded().data() );
|
||||
qWarning( R"(Blocking element "%s" due to not same domain)", url.toEncoded().data() );
|
||||
|
||||
return new BlockedNetworkReply( this );
|
||||
}
|
||||
|
@ -238,7 +237,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( QUrl c
|
|||
return dictionary->getResource( Utils::Url::path( url ).mid( 1 ).toUtf8().data() );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "getResource request error (%s) in \"%s\"\n", e.what(), dictionary->getName().c_str() );
|
||||
qWarning( "getResource request error (%s) in \"%s\"", e.what(), dictionary->getName().c_str() );
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +283,7 @@ ArticleResourceReply::ArticleResourceReply( QObject * parent,
|
|||
|
||||
if ( req->isFinished() ) {
|
||||
emit finishedSignal();
|
||||
GD_DPRINTF( "In-place finish.\n" );
|
||||
qDebug( "In-place finish." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -353,11 +352,11 @@ qint64 ArticleResourceReply::readData( char * out, qint64 maxSize )
|
|||
return 0;
|
||||
}
|
||||
|
||||
GD_DPRINTF( "====reading %lld of (%lld) bytes, %lld bytes readed . Finish status: %d",
|
||||
toRead,
|
||||
avail,
|
||||
alreadyRead,
|
||||
finished );
|
||||
qDebug( "====reading %lld of (%lld) bytes, %lld bytes readed . Finish status: %d",
|
||||
toRead,
|
||||
avail,
|
||||
alreadyRead,
|
||||
finished );
|
||||
|
||||
try {
|
||||
req->getDataSlice( alreadyRead, toRead, out );
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "ffmpegaudioplayer.hh"
|
||||
#include "multimediaaudioplayer.hh"
|
||||
#include "externalaudioplayer.hh"
|
||||
#include "gddebug.hh"
|
||||
|
||||
AudioPlayerFactory::AudioPlayerFactory( bool useInternalPlayer,
|
||||
InternalPlayerBackend internalPlayerBackend,
|
||||
|
@ -41,7 +40,7 @@ void AudioPlayerFactory::setPreferences( bool new_useInternalPlayer,
|
|||
setAudioPlaybackProgram( *externalPlayer );
|
||||
}
|
||||
else {
|
||||
gdWarning( "External player was expected, but it does not exist.\n" );
|
||||
qWarning( "External player was expected, but it does not exist." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "audiooutput.hh"
|
||||
#include "ffmpegaudio.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "utils.hh"
|
||||
#include <QAudioDevice>
|
||||
#include <QDataStream>
|
||||
|
@ -88,7 +87,7 @@ static int readAudioData( void * opaque, unsigned char * buffer, int bufferSize
|
|||
// QDataStream::readRawData() returns 0 at EOF => return AVERROR_EOF in this case.
|
||||
// An error is unlikely here, so just print a warning and return AVERROR_EOF too.
|
||||
if ( bytesRead < 0 ) {
|
||||
gdWarning( "readAudioData: error while reading raw data." );
|
||||
qWarning( "readAudioData: error while reading raw data." );
|
||||
}
|
||||
return bytesRead > 0 ? bytesRead : AVERROR_EOF;
|
||||
}
|
||||
|
@ -170,11 +169,11 @@ bool DecoderContext::openCodec( QString & errorString )
|
|||
|
||||
// 61 = FFmpeg 7.0 -> https://github.com/FFmpeg/FFmpeg/blob/release/7.0/libavcodec/version_major.h
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 61
|
||||
gdDebug( "Codec open: %s: channels: %d, rate: %d, format: %s\n",
|
||||
codec_->long_name,
|
||||
codecContext_->ch_layout.nb_channels,
|
||||
codecContext_->sample_rate,
|
||||
av_get_sample_fmt_name( codecContext_->sample_fmt ) );
|
||||
qDebug( "Codec open: %s: channels: %d, rate: %d, format: %s",
|
||||
codec_->long_name,
|
||||
codecContext_->ch_layout.nb_channels,
|
||||
codecContext_->sample_rate,
|
||||
av_get_sample_fmt_name( codecContext_->sample_fmt ) );
|
||||
|
||||
if ( !av_channel_layout_check( &codecContext_->ch_layout ) ) {
|
||||
av_channel_layout_default( &codecContext_->ch_layout, codecContext_->ch_layout.nb_channels );
|
||||
|
@ -193,11 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
|
|||
qDebug() << "swr_alloc_set_opts2 failed.";
|
||||
}
|
||||
#else
|
||||
gdDebug( "Codec open: %s: channels: %d, rate: %d, format: %s\n",
|
||||
codec_->long_name,
|
||||
codecContext_->channels,
|
||||
codecContext_->sample_rate,
|
||||
av_get_sample_fmt_name( codecContext_->sample_fmt ) );
|
||||
qDebug( "Codec open: %s: channels: %d, rate: %d, format: %s",
|
||||
codec_->long_name,
|
||||
codecContext_->channels,
|
||||
codecContext_->sample_rate,
|
||||
av_get_sample_fmt_name( codecContext_->sample_fmt ) );
|
||||
|
||||
auto layout = codecContext_->channel_layout;
|
||||
if ( !layout ) {
|
||||
|
@ -367,7 +366,7 @@ bool DecoderContext::normalizeAudio( AVFrame * frame, vector< uint8_t > & sample
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
// qDebug( "out_count:%d, out_nb_samples:%d, frame->nb_samples:%d \n", out_count, out_nb_samples, frame->nb_samples );
|
||||
// qDebug( "out_count:%d, out_nb_samples:%d, frame->nb_samples:%d ", out_count, out_nb_samples, frame->nb_samples );
|
||||
}
|
||||
|
||||
int actual_size = av_samples_get_buffer_size( nullptr, dst_channels, out_nb_samples, AV_SAMPLE_FMT_S16, 1 );
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/* This file is (c) 2013 Abs62
|
||||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||
|
||||
#include "gddebug.hh"
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QtCore5Compat/QTextCodec>
|
||||
|
||||
QFile * logFilePtr;
|
||||
|
||||
void gdWarning( const char * msg, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start( ap, msg );
|
||||
|
||||
qWarning() << QString().vasprintf( msg, ap );
|
||||
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
void gdDebug( const char * msg, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start( ap, msg );
|
||||
|
||||
qDebug().noquote() << QString().vasprintf( msg, ap );
|
||||
|
||||
va_end( ap );
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#ifdef NO_CONSOLE
|
||||
#define GD_DPRINTF( ... ) \
|
||||
do { \
|
||||
} while ( 0 )
|
||||
#define GD_FDPRINTF( ... ) \
|
||||
do { \
|
||||
} while ( 0 )
|
||||
#else
|
||||
#define GD_DPRINTF( ... ) gdDebug( __VA_ARGS__ )
|
||||
#define GD_FDPRINTF( ... ) fprintf( __VA_ARGS__ )
|
||||
#endif
|
||||
|
||||
void gdWarning( const char *, ... ) /* print warning message */
|
||||
#if defined( Q_CC_GNU ) && !defined( __INSURE__ )
|
||||
__attribute__( ( format( printf, 1, 2 ) ) )
|
||||
#endif
|
||||
;
|
||||
|
||||
void gdDebug( const char *, ... )
|
||||
#if defined( Q_CC_GNU ) && !defined( __INSURE__ )
|
||||
__attribute__( ( format( printf, 1, 2 ) ) )
|
||||
#endif
|
||||
;
|
||||
|
||||
extern QFile * logFilePtr;
|
2
src/common/logfileptr.cc
Normal file
2
src/common/logfileptr.cc
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "logfileptr.hh"
|
||||
QFile * logFilePtr;
|
3
src/common/logfileptr.hh
Normal file
3
src/common/logfileptr.hh
Normal file
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
#include <QFile>
|
||||
extern QFile * logFilePtr;
|
|
@ -8,7 +8,6 @@
|
|||
#include <QtXml>
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
#include "gddebug.hh"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
//this is a windows header file.
|
||||
|
@ -130,9 +129,9 @@ QString Preferences::sanitizeInputPhrase( QString const & inputWord ) const
|
|||
}
|
||||
|
||||
if ( limitInputPhraseLength && result.size() > inputPhraseLengthLimit ) {
|
||||
gdDebug( "Ignoring an input phrase %lld symbols long. The configured maximum input phrase length is %d symbols.",
|
||||
result.size(),
|
||||
inputPhraseLengthLimit );
|
||||
qDebug( "Ignoring an input phrase %lld symbols long. The configured maximum input phrase length is %d symbols.",
|
||||
result.size(),
|
||||
inputPhraseLengthLimit );
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -541,7 +540,7 @@ Class load()
|
|||
if ( !loadFromTemplate ) {
|
||||
// Load the config as usual
|
||||
if ( !dd.setContent( &configFile, false, &errorStr, &errorLine, &errorColumn ) ) {
|
||||
GD_DPRINTF( "Error: %s at %d,%d\n", errorStr.toLocal8Bit().constData(), errorLine, errorColumn );
|
||||
qDebug( "Error: %s at %d,%d", errorStr.toLocal8Bit().constData(), errorLine, errorColumn );
|
||||
throw exMalformedConfigFile();
|
||||
}
|
||||
}
|
||||
|
@ -554,7 +553,7 @@ Class load()
|
|||
QBuffer bufferedData( &data );
|
||||
|
||||
if ( !dd.setContent( &bufferedData, false, &errorStr, &errorLine, &errorColumn ) ) {
|
||||
GD_DPRINTF( "Error: %s at %d,%d\n", errorStr.toLocal8Bit().constData(), errorLine, errorColumn );
|
||||
qDebug( "Error: %s at %d,%d", errorStr.toLocal8Bit().constData(), errorLine, errorColumn );
|
||||
throw exMalformedConfigFile();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "chunkedstorage.hh"
|
||||
#include "langcoder.hh"
|
||||
#include "decompress.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "ftshelpers.hh"
|
||||
#include "htmlescape.hh"
|
||||
|
||||
|
@ -406,7 +405,7 @@ void AardDictionary::loadArticle( quint32 address, string & articleText, bool ra
|
|||
df.read( &articleBody.front(), articleSize );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "AARD: Failed loading article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "AARD: Failed loading article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
break;
|
||||
}
|
||||
catch ( ... ) {
|
||||
|
@ -566,14 +565,14 @@ void AardDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
}
|
||||
|
||||
|
||||
gdDebug( "Aard: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "Aard: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Aard: Failed building full-text search index for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Aard: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( QString::fromStdString( ftsIdxName ) );
|
||||
}
|
||||
}
|
||||
|
@ -589,7 +588,7 @@ void AardDictionary::getArticleText( uint32_t articleAddress, QString & headword
|
|||
text = Html::unescape( QString::fromUtf8( articleText.data(), articleText.size() ) );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Aard: Failed retrieving article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Aard: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -780,12 +779,12 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) {
|
||||
try {
|
||||
|
||||
gdDebug( "Aard: Building the index for dictionary: %s\n", fileName.c_str() );
|
||||
qDebug( "Aard: Building the index for dictionary: %s", fileName.c_str() );
|
||||
|
||||
{
|
||||
QFileInfo info( QString::fromUtf8( fileName.c_str() ) );
|
||||
if ( static_cast< quint64 >( info.size() ) > ULONG_MAX ) {
|
||||
gdWarning( "File %s is too large\n", fileName.c_str() );
|
||||
qWarning( "File %s is too large", fileName.c_str() );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -799,7 +798,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
if ( strncmp( dictHeader.signature, "aard", 4 )
|
||||
|| ( !has64bitIndex && strncmp( dictHeader.indexItemFormat, ">LL", 4 ) )
|
||||
|| strncmp( dictHeader.keyLengthFormat, ">H", 2 ) || strncmp( dictHeader.articleLengthFormat, ">L", 2 ) ) {
|
||||
gdWarning( "File %s is not in supported aard format\n", fileName.c_str() );
|
||||
qWarning( "File %s is not in supported aard format", fileName.c_str() );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -807,7 +806,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
quint32 size = qFromBigEndian( dictHeader.metaLength );
|
||||
|
||||
if ( size == 0 ) {
|
||||
gdWarning( "File %s has invalid metadata", fileName.c_str() );
|
||||
qWarning( "File %s has invalid metadata", fileName.c_str() );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -821,7 +820,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
map< string, string > meta = parseMetaData( metaStr );
|
||||
|
||||
if ( meta.empty() ) {
|
||||
gdWarning( "File %s has invalid metadata", fileName.c_str() );
|
||||
qWarning( "File %s has invalid metadata", fileName.c_str() );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -975,11 +974,11 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
idx.write( &idxHeader, sizeof( idxHeader ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Aard dictionary indexing failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "Aard dictionary indexing failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
continue;
|
||||
}
|
||||
catch ( ... ) {
|
||||
gdWarning( "Aard dictionary indexing failed\n" );
|
||||
qWarning( "Aard dictionary indexing failed" );
|
||||
continue;
|
||||
}
|
||||
} // if need to rebuild
|
||||
|
@ -987,7 +986,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< AardDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Aard dictionary initializing failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "Aard dictionary initializing failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "dictfile.hh"
|
||||
#include "folding.hh"
|
||||
#include "ftshelpers.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "htmlescape.hh"
|
||||
#include "langcoder.hh"
|
||||
#include "language.hh"
|
||||
|
@ -410,7 +409,7 @@ void BglDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
text = Html::unescape( QString::fromStdU32String( wstr ) );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "BGL: Failed retrieving article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "BGL: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,14 +425,14 @@ void BglDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
}
|
||||
|
||||
|
||||
gdDebug( "Bgl: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "Bgl: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Bgl: Failed building full-text search index for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Bgl: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( QString::fromStdString( ftsIdxName ) );
|
||||
}
|
||||
}
|
||||
|
@ -719,7 +718,7 @@ void BglArticleRequest::run()
|
|||
|
||||
} // try
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "BGL: Failed loading article from \"%s\", reason: %s\n", dict.getName().c_str(), ex.what() );
|
||||
qWarning( "BGL: Failed loading article from \"%s\", reason: %s", dict.getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -915,7 +914,7 @@ void BglResourceRequest::run()
|
|||
compressedData.size() )
|
||||
!= Z_OK
|
||||
|| decompressedLength != data.size() ) {
|
||||
gdWarning( "Failed to decompress resource \"%s\", ignoring it.\n", name.c_str() );
|
||||
qWarning( "Failed to decompress resource \"%s\", ignoring it.", name.c_str() );
|
||||
}
|
||||
else {
|
||||
hasAnyData = true;
|
||||
|
@ -993,14 +992,14 @@ protected:
|
|||
|
||||
void ResourceHandler::handleBabylonResource( string const & filename, char const * data, size_t size )
|
||||
{
|
||||
//GD_DPRINTF( "Handling resource file %s (%u bytes)\n", filename.c_str(), size );
|
||||
//qDebug( "Handling resource file %s (%u bytes)", filename.c_str(), size );
|
||||
|
||||
vector< unsigned char > compressedData( compressBound( size ) );
|
||||
|
||||
unsigned long compressedSize = compressedData.size();
|
||||
|
||||
if ( compress( &compressedData.front(), &compressedSize, (unsigned char const *)data, size ) != Z_OK ) {
|
||||
gdWarning( "Failed to compress the body of resource \"%s\", dropping it.\n", filename.c_str() );
|
||||
qWarning( "Failed to compress the body of resource \"%s\", dropping it.", filename.c_str() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1051,7 +1050,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) {
|
||||
// Building the index
|
||||
|
||||
gdDebug( "Bgl: Building the index for dictionary: %s\n", fileName.c_str() );
|
||||
qDebug( "Bgl: Building the index for dictionary: %s", fileName.c_str() );
|
||||
|
||||
try {
|
||||
Babylon b( fileName );
|
||||
|
@ -1063,7 +1062,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
std::string sourceCharset, targetCharset;
|
||||
|
||||
if ( !b.read( sourceCharset, targetCharset ) ) {
|
||||
gdWarning( "Failed to start reading from %s, skipping it\n", fileName.c_str() );
|
||||
qWarning( "Failed to start reading from %s, skipping it", fileName.c_str() );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1155,7 +1154,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
|
||||
idxHeader.chunksOffset = chunks.finish();
|
||||
|
||||
GD_DPRINTF( "Writing index...\n" );
|
||||
qDebug( "Writing index..." );
|
||||
|
||||
// Good. Now build the index
|
||||
|
||||
|
@ -1191,7 +1190,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
idx.write( &idxHeader, sizeof( idxHeader ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "BGL dictionary indexing failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "BGL dictionary indexing failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1199,7 +1198,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< BglDictionary >( dictId, indexFile, fileName ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "BGL dictionary initializing failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "BGL dictionary initializing failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "bgl_babylon.hh"
|
||||
#include "dictionary.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "globalregex.hh"
|
||||
#include "htmlescape.hh"
|
||||
#include "iconv.hh"
|
||||
|
@ -333,10 +332,10 @@ bool Babylon::read( const std::string & source_charset, const std::string & targ
|
|||
convertToUtf8( m_email, BGL_TARGET_CHARSET );
|
||||
convertToUtf8( m_copyright, BGL_TARGET_CHARSET );
|
||||
convertToUtf8( m_description, BGL_TARGET_CHARSET );
|
||||
GD_DPRINTF( "Default charset: %s\nSource Charset: %s\nTargetCharset: %s\n",
|
||||
m_defaultCharset.c_str(),
|
||||
m_sourceCharset.c_str(),
|
||||
m_targetCharset.c_str() );
|
||||
qDebug( "Default charset: %s\nSource Charset: %s\nTargetCharset: %s",
|
||||
m_defaultCharset.c_str(),
|
||||
m_sourceCharset.c_str(),
|
||||
m_targetCharset.c_str() );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -498,7 +497,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
|
|||
unsigned length = (unsigned char)block.data[ pos ] - 0x3F;
|
||||
|
||||
if ( length > len - a - 2 ) {
|
||||
GD_FDPRINTF( stderr, "Hidden displayed headword is too large %s\n", headword.c_str() );
|
||||
qWarning( "Hidden displayed headword is too large %s", headword.c_str() );
|
||||
pos += len - a;
|
||||
break;
|
||||
}
|
||||
|
@ -511,7 +510,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
|
|||
unsigned length = (unsigned char)block.data[ pos + 1 ];
|
||||
|
||||
if ( length > len - a - 2 ) {
|
||||
GD_FDPRINTF( stderr, "Displayed headword's length is too large for headword %s\n", headword.c_str() );
|
||||
qWarning( "Displayed headword's length is too large for headword %s", headword.c_str() );
|
||||
pos += len - a;
|
||||
break;
|
||||
}
|
||||
|
@ -525,7 +524,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
|
|||
unsigned length = qFromBigEndian( *reinterpret_cast< quint16 * >( block.data + pos + 1 ) );
|
||||
|
||||
if ( length > len - a - 3 ) {
|
||||
GD_FDPRINTF( stderr, "2-byte sized displayed headword for %s is too large\n", headword.c_str() );
|
||||
qWarning( "2-byte sized displayed headword for %s is too large", headword.c_str() );
|
||||
pos += len - a;
|
||||
break;
|
||||
}
|
||||
|
@ -541,9 +540,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
|
|||
unsigned length = (unsigned char)block.data[ pos + 2 ];
|
||||
|
||||
if ( length > len - a - 3 ) {
|
||||
GD_FDPRINTF( stderr,
|
||||
"1-byte-sized transcription's length is too large for headword %s\n",
|
||||
headword.c_str() );
|
||||
qWarning( "1-byte-sized transcription's length is too large for headword %s\n", headword.c_str() );
|
||||
pos += len - a;
|
||||
break;
|
||||
}
|
||||
|
@ -553,7 +550,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
|
|||
transcription = Iconv::toUtf8( "Windows-1252", block.data + pos + 3, length );
|
||||
}
|
||||
catch ( Iconv::Ex & e ) {
|
||||
qWarning( "Bgl: charset conversion error, no trancription processing's done: %s\n", e.what() );
|
||||
qWarning( "Bgl: charset conversion error, no trancription processing's done: %s", e.what() );
|
||||
transcription = std::string( block.data + pos + 3, length );
|
||||
}
|
||||
}
|
||||
|
@ -570,9 +567,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
|
|||
unsigned length = qFromBigEndian( *reinterpret_cast< quint16 * >( block.data + pos + 2 ) );
|
||||
|
||||
if ( length > len - a - 4 ) {
|
||||
GD_FDPRINTF( stderr,
|
||||
"2-byte-sized transcription's length is too large for headword %s\n",
|
||||
headword.c_str() );
|
||||
qWarning( "2-byte-sized transcription's length is too large for headword %s\n", headword.c_str() );
|
||||
pos += len - a;
|
||||
break;
|
||||
}
|
||||
|
@ -582,7 +577,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
|
|||
transcription = Iconv::toUtf8( "Windows-1252", block.data + pos + 4, length );
|
||||
}
|
||||
catch ( Iconv::Ex & e ) {
|
||||
qWarning( "Bgl: charset conversion error, no transcription processing's done: %s\n", e.what() );
|
||||
qWarning( "Bgl: charset conversion error, no transcription processing's done: %s", e.what() );
|
||||
transcription = std::string( block.data + pos + 4, length );
|
||||
}
|
||||
}
|
||||
|
@ -600,7 +595,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
|
|||
unsigned length = (unsigned char)block.data[ pos ] - 0x3F;
|
||||
|
||||
if ( length > len - a - 2 ) {
|
||||
GD_FDPRINTF( stderr, "Hidden transcription is too large %s\n", headword.c_str() );
|
||||
qWarning( "Hidden transcription is too large %s", headword.c_str() );
|
||||
pos += len - a;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "gddebug.hh"
|
||||
#include "wstring_qt.hh"
|
||||
#include "utils.hh"
|
||||
|
||||
|
@ -88,11 +87,11 @@ BtreeIndex::findArticles( wstring const & search_word, bool ignoreDiacritics, ui
|
|||
}
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Articles searching failed, error: %s\n", e.what() );
|
||||
qWarning( "Articles searching failed, error: %s", e.what() );
|
||||
result.clear();
|
||||
}
|
||||
catch ( ... ) {
|
||||
qWarning( "Articles searching failed\n" );
|
||||
qWarning( "Articles searching failed" );
|
||||
result.clear();
|
||||
}
|
||||
|
||||
|
@ -265,7 +264,7 @@ void BtreeWordSearchRequest::findMatches()
|
|||
break;
|
||||
}
|
||||
|
||||
//GD_DPRINTF( "offset = %u, size = %u\n", chainOffset - &leaf.front(), leaf.size() );
|
||||
//qDebug( "offset = %u, size = %u", chainOffset - &leaf.front(), leaf.size() );
|
||||
|
||||
vector< WordArticleLink > chain = dict.readChain( chainOffset );
|
||||
|
||||
|
@ -328,7 +327,7 @@ void BtreeWordSearchRequest::findMatches()
|
|||
if ( chainOffset >= leafEnd ) {
|
||||
// We're past the current leaf, fetch the next one
|
||||
|
||||
//GD_DPRINTF( "advancing\n" );
|
||||
//qDebug( "advancing" );
|
||||
|
||||
if ( nextLeaf ) {
|
||||
QMutexLocker _( dict.idxFileMutex );
|
||||
|
@ -342,7 +341,7 @@ void BtreeWordSearchRequest::findMatches()
|
|||
uint32_t leafEntries = *(uint32_t *)&leaf.front();
|
||||
|
||||
if ( leafEntries == 0xffffFFFF ) {
|
||||
//GD_DPRINTF( "bah!\n" );
|
||||
//qDebug( "bah!" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
@ -363,10 +362,10 @@ void BtreeWordSearchRequest::findMatches()
|
|||
}
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
qWarning( "Index searching failed: \"%s\", error: %s\n", dict.getName().c_str(), e.what() );
|
||||
qWarning( "Index searching failed: \"%s\", error: %s", dict.getName().c_str(), e.what() );
|
||||
}
|
||||
catch ( ... ) {
|
||||
gdWarning( "Index searching failed: \"%s\"\n", dict.getName().c_str() );
|
||||
qWarning( "Index searching failed: \"%s\"", dict.getName().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,7 +420,7 @@ void BtreeIndex::readNode( uint32_t offset, vector< char > & out )
|
|||
uint32_t uncompressedSize = idxFile->read< uint32_t >();
|
||||
uint32_t compressedSize = idxFile->read< uint32_t >();
|
||||
|
||||
//GD_DPRINTF( "%x,%x\n", uncompressedSize, compressedSize );
|
||||
//qDebug( "%x,%x", uncompressedSize, compressedSize );
|
||||
|
||||
out.resize( uncompressedSize );
|
||||
|
||||
|
@ -502,7 +501,7 @@ char const * BtreeIndex::findChainOffsetExactOrPrefix(
|
|||
if ( leafEntries == 0xffffFFFF ) {
|
||||
// A node
|
||||
|
||||
//GD_DPRINTF( "=>a node\n" );
|
||||
//qDebug( "=>a node" );
|
||||
|
||||
uint32_t const * offsets = (uint32_t *)leaf + 1;
|
||||
|
||||
|
@ -588,13 +587,13 @@ char const * BtreeIndex::findChainOffsetExactOrPrefix(
|
|||
currentNodeOffset = offsets[ entry + 1 ];
|
||||
}
|
||||
|
||||
//GD_DPRINTF( "reading node at %x\n", currentNodeOffset );
|
||||
//qDebug( "reading node at %x", currentNodeOffset );
|
||||
readNode( currentNodeOffset, extLeaf );
|
||||
leaf = &extLeaf.front();
|
||||
leafEnd = leaf + extLeaf.size();
|
||||
}
|
||||
else {
|
||||
//GD_DPRINTF( "=>a leaf\n" );
|
||||
//qDebug( "=>a leaf" );
|
||||
// A leaf
|
||||
|
||||
// If this leaf is the root, there's no next leaf, it just can't be.
|
||||
|
@ -627,7 +626,7 @@ char const * BtreeIndex::findChainOffsetExactOrPrefix(
|
|||
|
||||
memcpy( &chainSize, ptr, sizeof( uint32_t ) );
|
||||
|
||||
//GD_DPRINTF( "%s + %s\n", ptr + sizeof( uint32_t ), ptr + sizeof( uint32_t ) + strlen( ptr + sizeof( uint32_t ) ) + 1 );
|
||||
//qDebug( "%s + %s", ptr + sizeof( uint32_t ), ptr + sizeof( uint32_t ) + strlen( ptr + sizeof( uint32_t ) ) + 1 );
|
||||
|
||||
ptr += sizeof( uint32_t ) + chainSize;
|
||||
}
|
||||
|
@ -640,7 +639,7 @@ char const * BtreeIndex::findChainOffsetExactOrPrefix(
|
|||
unsigned windowSize = chainOffsets.size();
|
||||
|
||||
for ( ;; ) {
|
||||
//GD_DPRINTF( "window = %u, ws = %u\n", window - &chainOffsets.front(), windowSize );
|
||||
//qDebug( "window = %u, ws = %u", window - &chainOffsets.front(), windowSize );
|
||||
|
||||
char const ** chainToCheck = window + windowSize / 2;
|
||||
ptr = *chainToCheck;
|
||||
|
@ -1056,7 +1055,7 @@ IndexInfo buildIndex( IndexedWords const & indexedWords, File::Index & file )
|
|||
btreeMaxElements = BtreeMaxElements;
|
||||
}
|
||||
|
||||
GD_DPRINTF( "Building a tree of %u elements\n", (unsigned)btreeMaxElements );
|
||||
qDebug( "Building a tree of %u elements", (unsigned)btreeMaxElements );
|
||||
|
||||
|
||||
uint32_t lastLeafOffset = 0;
|
||||
|
@ -1416,7 +1415,7 @@ bool BtreeDictionary::getHeadwords( QStringList & headwords )
|
|||
}
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Failed headwords retrieving for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Failed headwords retrieving for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
|
||||
return headwords.size() > 0;
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include <list>
|
||||
#include <wctype.h>
|
||||
#include <stdlib.h>
|
||||
#include "gddebug.hh"
|
||||
#include "ftshelpers.hh"
|
||||
#include <QDir>
|
||||
#include <QUrl>
|
||||
|
@ -456,14 +455,14 @@ void DictdDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
}
|
||||
|
||||
|
||||
gdDebug( "DictD: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "DictD: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "DictD: Failed building full-text search index for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "DictD: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( QString::fromStdString( ftsIdxName ) );
|
||||
}
|
||||
}
|
||||
|
@ -537,7 +536,7 @@ void DictdDictionary::getArticleText( uint32_t articleAddress, QString & headwor
|
|||
}
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "DictD: Failed retrieving article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "DictD: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,7 +588,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
// Building the index
|
||||
string dictionaryName = nameFromFileName( dictFiles[ 0 ] );
|
||||
|
||||
gdDebug( "DictD: Building the index for dictionary: %s\n", dictionaryName.c_str() );
|
||||
qDebug( "DictD: Building the index for dictionary: %s", dictionaryName.c_str() );
|
||||
|
||||
initializing.indexingDictionary( dictionaryName );
|
||||
|
||||
|
@ -628,7 +627,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
if ( tab3 ) {
|
||||
char * tab4 = strchr( tab3 + 1, '\t' );
|
||||
if ( tab4 ) {
|
||||
GD_DPRINTF( "Warning: too many tabs present, skipping: %s\n", buf );
|
||||
qDebug( "Warning: too many tabs present, skipping: %s", buf );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -673,7 +672,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
*endEol = 0;
|
||||
}
|
||||
|
||||
GD_DPRINTF( "DICT NAME: '%s'\n", eol );
|
||||
qDebug( "DICT NAME: '%s'", eol );
|
||||
dictionaryName = eol;
|
||||
}
|
||||
}
|
||||
|
@ -685,12 +684,12 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
}
|
||||
}
|
||||
else {
|
||||
GD_DPRINTF( "Warning: only a single tab present, skipping: %s\n", buf );
|
||||
qDebug( "Warning: only a single tab present, skipping: %s", buf );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
GD_DPRINTF( "Warning: no tabs present, skipping: %s\n", buf );
|
||||
qDebug( "Warning: no tabs present, skipping: %s", buf );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -734,7 +733,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< DictdDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Dictd dictionary \"%s\" reading failed, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "Dictd dictionary \"%s\" reading failed, error: %s", fileName.c_str(), e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "langcoder.hh"
|
||||
#include "wstring_qt.hh"
|
||||
#include "indexedzip.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "tiff.hh"
|
||||
#include "ftshelpers.hh"
|
||||
#include <map>
|
||||
|
@ -375,7 +374,7 @@ void DslDictionary::doDeferredInit()
|
|||
memcpy( &total, abrvBlock, sizeof( uint32_t ) );
|
||||
abrvBlock += sizeof( uint32_t );
|
||||
|
||||
GD_DPRINTF( "Loading %u abbrv\n", total );
|
||||
qDebug( "Loading %u abbrv", total );
|
||||
|
||||
while ( total-- ) {
|
||||
uint32_t keySz;
|
||||
|
@ -495,7 +494,7 @@ void DslDictionary::loadArticle( uint32_t address,
|
|||
memcpy( &articleOffset, articleProps, sizeof( articleOffset ) );
|
||||
memcpy( &articleSize, articleProps + sizeof( articleOffset ), sizeof( articleSize ) );
|
||||
|
||||
GD_DPRINTF( "offset = %x\n", articleOffset );
|
||||
qDebug( "offset = %x", articleOffset );
|
||||
|
||||
|
||||
char * articleBody;
|
||||
|
@ -994,11 +993,11 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
result += "<br />";
|
||||
}
|
||||
else {
|
||||
gdWarning( R"(DSL: Unknown tag "%s" with attributes "%s" found in "%s", article "%s".)",
|
||||
QString::fromStdU32String( node.tagName ).toUtf8().data(),
|
||||
QString::fromStdU32String( node.tagAttrs ).toUtf8().data(),
|
||||
getName().c_str(),
|
||||
QString::fromStdU32String( currentHeadword ).toUtf8().data() );
|
||||
qWarning( R"(DSL: Unknown tag "%s" with attributes "%s" found in "%s", article "%s".)",
|
||||
QString::fromStdU32String( node.tagName ).toUtf8().data(),
|
||||
QString::fromStdU32String( node.tagAttrs ).toUtf8().data(),
|
||||
getName().c_str(),
|
||||
QString::fromStdU32String( currentHeadword ).toUtf8().data() );
|
||||
|
||||
result += "<span class=\"dsl_unknown\">[" + string( QString::fromStdU32String( node.tagName ).toUtf8().data() );
|
||||
if ( !node.tagAttrs.empty() ) {
|
||||
|
@ -1106,14 +1105,14 @@ void DslDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
}
|
||||
|
||||
|
||||
gdDebug( "Dsl: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "Dsl: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "DSL: Failed building full-text search index for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "DSL: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( ftsIdxName.c_str() );
|
||||
}
|
||||
}
|
||||
|
@ -1534,7 +1533,7 @@ void DslArticleRequest::run()
|
|||
articleText += articleAfter;
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "DSL: Failed loading article from \"%s\", reason: %s\n", dict.getName().c_str(), ex.what() );
|
||||
qWarning( "DSL: Failed loading article from \"%s\", reason: %s", dict.getName().c_str(), ex.what() );
|
||||
articleText =
|
||||
string( "<span class=\"dsl_article\">" ) + QObject::tr( "Article loading error" ).toStdString() + "</span>";
|
||||
}
|
||||
|
@ -1609,7 +1608,7 @@ void DslResourceRequest::run()
|
|||
|
||||
string n = dict.getContainingFolder().toStdString() + Utils::Fs::separator() + resourceName;
|
||||
|
||||
GD_DPRINTF( "dsl resource name is %s\n", n.c_str() );
|
||||
qDebug( "dsl resource name is %s", n.c_str() );
|
||||
|
||||
try {
|
||||
try {
|
||||
|
@ -1661,10 +1660,10 @@ void DslResourceRequest::run()
|
|||
hasAnyData = true;
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "DSL: Failed loading resource \"%s\" for \"%s\", reason: %s\n",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
qWarning( "DSL: Failed loading resource \"%s\" for \"%s\", reason: %s",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
// Resource not loaded -- we don't set the hasAnyData flag then
|
||||
}
|
||||
|
||||
|
@ -1769,8 +1768,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
// Building the index
|
||||
initializing.indexingDictionary( Utf8::encode( scanner.getDictionaryName() ) );
|
||||
|
||||
gdDebug( "Dsl: Building the index for dictionary: %s\n",
|
||||
QString::fromStdU32String( scanner.getDictionaryName() ).toUtf8().data() );
|
||||
qDebug( "Dsl: Building the index for dictionary: %s",
|
||||
QString::fromStdU32String( scanner.getDictionaryName() ).toUtf8().data() );
|
||||
|
||||
File::Index idx( indexFile, QIODevice::WriteOnly );
|
||||
|
||||
|
@ -1836,7 +1835,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
expandOptionalParts( curString, &keys );
|
||||
|
||||
if ( !abrvScanner.readNextLineWithoutComments( curString, curOffset ) || curString.empty() ) {
|
||||
gdWarning( "Premature end of file %s\n", abrvFileName.c_str() );
|
||||
qWarning( "Premature end of file %s", abrvFileName.c_str() );
|
||||
eof = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1875,7 +1874,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
chunks.addToBlock( &sz, sizeof( uint32_t ) );
|
||||
|
||||
for ( const auto & i : abrv ) {
|
||||
// GD_DPRINTF( "%s:%s\n", i->first.c_str(), i->second.c_str() );
|
||||
// qDebug( "%s:%s", i->first.c_str(), i->second.c_str() );
|
||||
|
||||
sz = i.first.size();
|
||||
chunks.addToBlock( &sz, sizeof( uint32_t ) );
|
||||
|
@ -1886,7 +1885,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
}
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Error reading abrv file \"%s\", error: %s. Skipping it.\n", abrvFileName.c_str(), e.what() );
|
||||
qWarning( "Error reading abrv file \"%s\", error: %s. Skipping it.", abrvFileName.c_str(), e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1916,7 +1915,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
// characters are blank, too.
|
||||
for ( size_t x = 1; x < curString.size(); ++x ) {
|
||||
if ( !isDslWs( curString[ x ] ) ) {
|
||||
gdWarning( "Garbage string in %s at offset 0x%lX\n", fileName.c_str(), curOffset );
|
||||
qWarning( "Garbage string in %s at offset 0x%lX", fileName.c_str(), curOffset );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1932,13 +1931,13 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
|
||||
uint32_t articleOffset = curOffset;
|
||||
|
||||
//GD_DPRINTF( "Headword: %ls\n", curString.c_str() );
|
||||
//qDebug( "Headword: %ls", curString.c_str() );
|
||||
|
||||
// More headwords may follow
|
||||
|
||||
for ( ;; ) {
|
||||
if ( !( hasString = scanner.readNextLineWithoutComments( curString, curOffset ) ) ) {
|
||||
gdWarning( "Premature end of file %s\n", fileName.c_str() );
|
||||
qWarning( "Premature end of file %s", fileName.c_str() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1996,11 +1995,11 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
|
||||
if ( !hasString || ( curString.size() && !isDslWs( curString[ 0 ] ) ) ) {
|
||||
if ( insideInsided ) {
|
||||
gdWarning( "Unclosed tag '@' at line %i", dogLine );
|
||||
qWarning( "Unclosed tag '@' at line %i", dogLine );
|
||||
insidedCards.append( InsidedCard( offset, curOffset - offset, insidedHeadwords ) );
|
||||
}
|
||||
if ( noSignificantLines ) {
|
||||
gdWarning( "Orphan headword at line %i", headwordLine );
|
||||
qWarning( "Orphan headword at line %i", headwordLine );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -2014,7 +2013,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
}
|
||||
else {
|
||||
if ( wasEmptyLine && !Folding::applyWhitespaceOnly( curString ).empty() ) {
|
||||
gdWarning( "Orphan string at line %i", scanner.getLinesRead() - 1 );
|
||||
qWarning( "Orphan string at line %i", scanner.getLinesRead() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2035,7 +2034,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
else {
|
||||
// Embedded card tag must be placed at first position in line after spaces
|
||||
if ( !isAtSignFirst( curString ) ) {
|
||||
gdWarning( "Unescaped '@' symbol at line %i", scanner.getLinesRead() - 1 );
|
||||
qWarning( "Unescaped '@' symbol at line %i", scanner.getLinesRead() - 1 );
|
||||
|
||||
if ( insideInsided ) {
|
||||
linesInsideCard++;
|
||||
|
@ -2125,7 +2124,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
// If there was a zip file, index it too
|
||||
|
||||
if ( zipFileName.size() ) {
|
||||
GD_DPRINTF( "Indexing zip file\n" );
|
||||
qDebug( "Indexing zip file" );
|
||||
|
||||
idxHeader.hasZipFile = 1;
|
||||
|
||||
|
@ -2181,7 +2180,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< DslDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "DSL dictionary reading failed: %s:%u, error: %s\n", fileName.c_str(), atLine, e.what() );
|
||||
qWarning( "DSL dictionary reading failed: %s:%u, error: %s", fileName.c_str(), atLine, e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "folding.hh"
|
||||
#include "langcoder.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "ufile.hh"
|
||||
#include "utf8.hh"
|
||||
|
||||
|
@ -119,10 +118,10 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, wstring co
|
|||
if ( !atSignFirstInLine() ) {
|
||||
// Not insided card
|
||||
if ( dictName.empty() ) {
|
||||
gdWarning( "Unescaped '@' symbol found" );
|
||||
qWarning( "Unescaped '@' symbol found" );
|
||||
}
|
||||
else {
|
||||
gdWarning( "Unescaped '@' symbol found in \"%s\"", dictName.c_str() );
|
||||
qWarning( "Unescaped '@' symbol found in \"%s\"", dictName.c_str() );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -246,16 +245,16 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, wstring co
|
|||
}
|
||||
catch ( std::exception & ex ) {
|
||||
if ( !dictionaryName.empty() ) {
|
||||
gdWarning( R"(DSL: Unfinished tag "%s" with attributes "%s" found in "%s", article "%s".)",
|
||||
QString::fromStdU32String( name ).toUtf8().data(),
|
||||
QString::fromStdU32String( attrs ).toUtf8().data(),
|
||||
dictionaryName.c_str(),
|
||||
QString::fromStdU32String( headword ).toUtf8().data() );
|
||||
qWarning( R"(DSL: Unfinished tag "%s" with attributes "%s" found in "%s", article "%s".)",
|
||||
QString::fromStdU32String( name ).toUtf8().data(),
|
||||
QString::fromStdU32String( attrs ).toUtf8().data(),
|
||||
dictionaryName.c_str(),
|
||||
QString::fromStdU32String( headword ).toUtf8().data() );
|
||||
}
|
||||
else {
|
||||
gdWarning( R"(DSL: Unfinished tag "%s" with attributes "%s" found)",
|
||||
QString::fromStdU32String( name ).toUtf8().data(),
|
||||
QString::fromStdU32String( attrs ).toUtf8().data() );
|
||||
qWarning( R"(DSL: Unfinished tag "%s" with attributes "%s" found)",
|
||||
QString::fromStdU32String( name ).toUtf8().data(),
|
||||
QString::fromStdU32String( attrs ).toUtf8().data() );
|
||||
}
|
||||
|
||||
throw ex;
|
||||
|
@ -678,16 +677,16 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, wstring co
|
|||
unsigned const unclosedTagCount = 1 + std::count_if( it, stack.end(), MustTagBeClosed() );
|
||||
|
||||
if ( dictName.empty() ) {
|
||||
gdWarning( "Warning: %u tag(s) were unclosed, first tag name \"%s\".\n",
|
||||
unclosedTagCount,
|
||||
firstTagName.constData() );
|
||||
qWarning( "Warning: %u tag(s) were unclosed, first tag name \"%s\".",
|
||||
unclosedTagCount,
|
||||
firstTagName.constData() );
|
||||
}
|
||||
else {
|
||||
gdWarning( "Warning: %u tag(s) were unclosed in \"%s\", article \"%s\", first tag name \"%s\".\n",
|
||||
unclosedTagCount,
|
||||
dictName.c_str(),
|
||||
QString::fromStdU32String( headword ).toUtf8().constData(),
|
||||
firstTagName.constData() );
|
||||
qWarning( "Warning: %u tag(s) were unclosed in \"%s\", article \"%s\", first tag name \"%s\".",
|
||||
unclosedTagCount,
|
||||
dictName.c_str(),
|
||||
QString::fromStdU32String( headword ).toUtf8().constData(),
|
||||
firstTagName.constData() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -787,14 +786,14 @@ void ArticleDom::closeTag( wstring const & name, list< Node * > & stack, bool wa
|
|||
}
|
||||
else if ( warn ) {
|
||||
if ( !dictionaryName.empty() ) {
|
||||
gdWarning( R"(No corresponding opening tag for closing tag "%s" found in "%s", article "%s".)",
|
||||
QString::fromStdU32String( name ).toUtf8().data(),
|
||||
dictionaryName.c_str(),
|
||||
QString::fromStdU32String( headword ).toUtf8().data() );
|
||||
qWarning( R"(No corresponding opening tag for closing tag "%s" found in "%s", article "%s".)",
|
||||
QString::fromStdU32String( name ).toUtf8().data(),
|
||||
dictionaryName.c_str(),
|
||||
QString::fromStdU32String( headword ).toUtf8().data() );
|
||||
}
|
||||
else {
|
||||
gdWarning( "No corresponding opening tag for closing tag \"%s\" found.",
|
||||
QString::fromStdU32String( name ).toUtf8().data() );
|
||||
qWarning( "No corresponding opening tag for closing tag \"%s\" found.",
|
||||
QString::fromStdU32String( name ).toUtf8().data() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -975,7 +974,7 @@ DslScanner::DslScanner( string const & fileName ):
|
|||
// The encoding
|
||||
if ( !needExactEncoding ) {
|
||||
// We don't need that!
|
||||
GD_FDPRINTF( stderr, "Warning: encoding was specified in a Unicode file, ignoring.\n" );
|
||||
qWarning( "Warning: encoding was specified in a Unicode file, ignoring." );
|
||||
}
|
||||
else if ( !arg.compare( U"Latin" ) ) {
|
||||
encoding = Utf8::Windows1252;
|
||||
|
@ -1121,7 +1120,7 @@ void processUnsortedParts( wstring & str, bool strip )
|
|||
--refCount;
|
||||
|
||||
if ( refCount < 0 ) {
|
||||
GD_FDPRINTF( stderr, "Warning: an unmatched closing brace was encountered.\n" );
|
||||
qWarning( "Warning: an unmatched closing brace was encountered." );
|
||||
refCount = 0;
|
||||
// But we remove that thing either way
|
||||
str.erase( x, 1 );
|
||||
|
@ -1146,7 +1145,7 @@ void processUnsortedParts( wstring & str, bool strip )
|
|||
}
|
||||
|
||||
if ( strip && refCount ) {
|
||||
GD_FDPRINTF( stderr, "Warning: unclosed brace(s) encountered.\n" );
|
||||
qWarning( "Warning: unclosed brace(s) encountered." );
|
||||
str.erase( startPos );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <string>
|
||||
#include "btreeidx.hh"
|
||||
#include "folding.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "chunkedstorage.hh"
|
||||
#include "filetype.hh"
|
||||
#include "ftshelpers.hh"
|
||||
|
@ -414,16 +413,14 @@ void EpwingDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
return;
|
||||
|
||||
|
||||
gdDebug( "Epwing: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "Epwing: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Epwing: Failed building full-text search index for \"%s\", reason: %s\n",
|
||||
getName().c_str(),
|
||||
ex.what() );
|
||||
qWarning( "Epwing: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( QString::fromStdString( ftsIdxName ) );
|
||||
}
|
||||
}
|
||||
|
@ -862,10 +859,10 @@ void EpwingResourceRequest::run()
|
|||
}
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Epwing: Failed loading resource \"%s\" for \"%s\", reason: %s\n",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
qWarning( "Epwing: Failed loading resource \"%s\" for \"%s\", reason: %s",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
// Resource not loaded -- we don't set the hasAnyData flag then
|
||||
}
|
||||
|
||||
|
@ -1139,7 +1136,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
subBooksNumber = dict.setBook( mainDirectory );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Epwing dictionary initializing failed: %s, error: %s\n", mainDirectory.c_str(), e.what() );
|
||||
qWarning( "Epwing dictionary initializing failed: %s, error: %s", mainDirectory.c_str(), e.what() );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1174,7 +1171,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
string indexFile = indicesDir + dictId;
|
||||
|
||||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) {
|
||||
gdDebug( "Epwing: Building the index for dictionary in directory %s\n", dir.toUtf8().data() );
|
||||
qDebug( "Epwing: Building the index for dictionary in directory %s", dir.toUtf8().data() );
|
||||
|
||||
QString str = dict.title();
|
||||
QByteArray nameData = str.toUtf8();
|
||||
|
@ -1254,7 +1251,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< EpwingDictionary >( dictId, indexFile, dictFiles, sb ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Epwing dictionary initializing failed: %s, error: %s\n", dir.toUtf8().data(), e.what() );
|
||||
qWarning( "Epwing dictionary initializing failed: %s, error: %s", dir.toUtf8().data(), e.what() );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#include <QTextStream>
|
||||
#include <QTextDocumentFragment>
|
||||
#include <QHash>
|
||||
#include "gddebug.hh"
|
||||
|
||||
#include "audiolink.hh"
|
||||
#include "wstring.hh"
|
||||
#include "wstring_qt.hh"
|
||||
|
@ -577,7 +575,7 @@ QString EpwingBook::createCacheDir( QString const & dirName )
|
|||
QFileInfo info( mainCacheDir );
|
||||
if ( !info.exists() || !info.isDir() ) {
|
||||
if ( !dir.mkdir( mainCacheDir ) ) {
|
||||
gdWarning( "Epwing: can't create cache directory \"%s\"", mainCacheDir.toUtf8().data() );
|
||||
qWarning( "Epwing: can't create cache directory \"%s\"", mainCacheDir.toUtf8().data() );
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
@ -586,7 +584,7 @@ QString EpwingBook::createCacheDir( QString const & dirName )
|
|||
info = QFileInfo( cacheDir );
|
||||
if ( !info.exists() || !info.isDir() ) {
|
||||
if ( !dir.mkdir( cacheDir ) ) {
|
||||
gdWarning( "Epwing: can't create cache directory \"%s\"", cacheDir.toUtf8().data() );
|
||||
qWarning( "Epwing: can't create cache directory \"%s\"", cacheDir.toUtf8().data() );
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
@ -1263,7 +1261,7 @@ const char * EpwingBook::beginDecoration( unsigned int code )
|
|||
str = "<sup>";
|
||||
break;
|
||||
default:
|
||||
gdWarning( "Epwing: Unknown decoration code %i", code );
|
||||
qWarning( "Epwing: Unknown decoration code %i", code );
|
||||
code = UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
@ -1285,7 +1283,7 @@ const char * EpwingBook::endDecoration( unsigned int code )
|
|||
storedCode = decorationStack.pop();
|
||||
|
||||
if ( storedCode != code ) {
|
||||
gdWarning( "Epwing: tags mismatch detected" );
|
||||
qWarning( "Epwing: tags mismatch detected" );
|
||||
if ( storedCode == UNKNOWN )
|
||||
storedCode = code;
|
||||
}
|
||||
|
@ -1405,7 +1403,7 @@ QByteArray EpwingBook::handleColorImage( EB_Hook_Code code, const unsigned int *
|
|||
EB_Error_Code ret = eb_set_binary_color_graphic( &book, &pos );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_set_binary_color_graphic", ret );
|
||||
gdWarning( "Epwing image retrieve error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing image retrieve error: %s", error_string.toUtf8().data() );
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
|
@ -1443,7 +1441,7 @@ QByteArray EpwingBook::handleColorImage( EB_Hook_Code code, const unsigned int *
|
|||
ret = eb_read_binary( &book, BinaryBufferSize, buffer.data(), &length );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_read_binary", ret );
|
||||
gdWarning( "Epwing image retrieve error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing image retrieve error: %s", error_string.toUtf8().data() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1480,7 +1478,7 @@ QByteArray EpwingBook::handleMonoImage( EB_Hook_Code code, const unsigned int *
|
|||
EB_Error_Code ret = eb_set_binary_mono_graphic( &book, &pos, monoWidth, monoHeight );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_set_binary_mono_graphic", ret );
|
||||
gdWarning( "Epwing image retrieve error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing image retrieve error: %s", error_string.toUtf8().data() );
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
|
@ -1515,7 +1513,7 @@ QByteArray EpwingBook::handleMonoImage( EB_Hook_Code code, const unsigned int *
|
|||
ret = eb_read_binary( &book, BinaryBufferSize, buffer.data(), &length );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_read_binary", ret );
|
||||
gdWarning( "Epwing image retrieve error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing image retrieve error: %s", error_string.toUtf8().data() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1585,7 +1583,7 @@ QByteArray EpwingBook::handleWave( EB_Hook_Code code, const unsigned int * argv
|
|||
EB_Error_Code ret = eb_read_binary( &book, BinaryBufferSize, buffer.data(), &length );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_read_binary", ret );
|
||||
gdWarning( "Epwing sound retrieve error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing sound retrieve error: %s", error_string.toUtf8().data() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1652,7 +1650,7 @@ QByteArray EpwingBook::handleMpeg( EB_Hook_Code code, const unsigned int * argv
|
|||
EB_Error_Code ret = eb_read_binary( &book, BinaryBufferSize, buffer.data(), &length );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_read_binary", ret );
|
||||
gdWarning( "Epwing movie retrieve error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing movie retrieve error: %s", error_string.toUtf8().data() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1720,7 +1718,7 @@ QByteArray EpwingBook::handleNarrowFont( const unsigned int * argv, bool text_on
|
|||
EB_Error_Code ret = eb_narrow_font_character_bitmap( &book, *argv, bitmap );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_narrow_font_character_bitmap", ret );
|
||||
gdWarning( "Epwing: Font retrieve error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing: Font retrieve error: %s", error_string.toUtf8().data() );
|
||||
return QByteArray( "?" );
|
||||
}
|
||||
|
||||
|
@ -1729,7 +1727,7 @@ QByteArray EpwingBook::handleNarrowFont( const unsigned int * argv, bool text_on
|
|||
ret = eb_bitmap_to_png( bitmap, 8, 16, buff, &nlen );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_bitmap_to_png", ret );
|
||||
gdWarning( "Epwing: Font retrieve error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing: Font retrieve error: %s", error_string.toUtf8().data() );
|
||||
return QByteArray( "?" );
|
||||
}
|
||||
|
||||
|
@ -1784,7 +1782,7 @@ QByteArray EpwingBook::handleWideFont( const unsigned int * argv, bool text_only
|
|||
EB_Error_Code ret = eb_wide_font_character_bitmap( &book, *argv, bitmap );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_wide_font_character_bitmap", ret );
|
||||
gdWarning( "Epwing: Font retrieve error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing: Font retrieve error: %s", error_string.toUtf8().data() );
|
||||
return QByteArray( "?" );
|
||||
}
|
||||
|
||||
|
@ -1793,7 +1791,7 @@ QByteArray EpwingBook::handleWideFont( const unsigned int * argv, bool text_only
|
|||
ret = eb_bitmap_to_png( bitmap, 16, 16, buff, &wlen );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_bitmap_to_png", ret );
|
||||
gdWarning( "Epwing: Font retrieve error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing: Font retrieve error: %s", error_string.toUtf8().data() );
|
||||
return QByteArray( "?" );
|
||||
}
|
||||
|
||||
|
@ -1873,14 +1871,14 @@ bool EpwingBook::getMatches( QString word, QList< QString > & matches )
|
|||
EB_Error_Code ret = eb_search_word( &book, bword.data() );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_search_word", ret );
|
||||
gdWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = eb_hit_list( &book, 10, hits, &hitCount );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_hit_list", ret );
|
||||
gdWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1889,14 +1887,14 @@ bool EpwingBook::getMatches( QString word, QList< QString > & matches )
|
|||
EB_Error_Code ret = eb_search_word( &book, bword2.data() );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_search_word", ret );
|
||||
gdWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = eb_hit_list( &book, 10, hits, &hitCount );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_hit_list", ret );
|
||||
gdWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1944,14 +1942,14 @@ bool EpwingBook::getArticlePos( QString word, QList< int > & pages, QList< int >
|
|||
EB_Error_Code ret = eb_search_exactword( &book, bword.data() );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_search_word", ret );
|
||||
gdWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = eb_hit_list( &book, HitsBufferSize, hits, &hitCount );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_hit_list", ret );
|
||||
gdWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1960,14 +1958,14 @@ bool EpwingBook::getArticlePos( QString word, QList< int > & pages, QList< int >
|
|||
EB_Error_Code ret = eb_search_exactword( &book, bword2.data() );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_search_word", ret );
|
||||
gdWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = eb_hit_list( &book, HitsBufferSize, hits, &hitCount );
|
||||
if ( ret != EB_SUCCESS ) {
|
||||
setErrorString( "eb_hit_list", ret );
|
||||
gdWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
qWarning( "Epwing word search error: %s", error_string.toUtf8().data() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "audiolink.hh"
|
||||
#include "htmlescape.hh"
|
||||
#include "utf8.hh"
|
||||
#include "gddebug.hh"
|
||||
|
||||
namespace Forvo {
|
||||
|
||||
|
@ -164,7 +163,7 @@ ForvoArticleRequest::ForvoArticleRequest( wstring const & str,
|
|||
|
||||
void ForvoArticleRequest::addQuery( QNetworkAccessManager & mgr, wstring const & str )
|
||||
{
|
||||
gdDebug( "Forvo: requesting article %s\n", QString::fromStdU32String( str ).toUtf8().data() );
|
||||
qDebug( "Forvo: requesting article %s", QString::fromStdU32String( str ).toUtf8().data() );
|
||||
|
||||
QString key = apiKey;
|
||||
|
||||
|
@ -179,7 +178,7 @@ void ForvoArticleRequest::addQuery( QNetworkAccessManager & mgr, wstring const &
|
|||
+ "/language/" + languageCode + "/order/rate-desc" )
|
||||
.toUtf8() );
|
||||
|
||||
// GD_DPRINTF( "req: %s\n", reqUrl.toEncoded().data() );
|
||||
// qDebug( "req: %s", reqUrl.toEncoded().data() );
|
||||
|
||||
sptr< QNetworkReply > netReply = std::shared_ptr< QNetworkReply >( mgr.get( QNetworkRequest( reqUrl ) ) );
|
||||
|
||||
|
@ -188,7 +187,7 @@ void ForvoArticleRequest::addQuery( QNetworkAccessManager & mgr, wstring const &
|
|||
|
||||
void ForvoArticleRequest::requestFinished( QNetworkReply * r )
|
||||
{
|
||||
GD_DPRINTF( "Finished.\n" );
|
||||
qDebug( "Finished." );
|
||||
|
||||
if ( isFinished() ) { // Was cancelled
|
||||
return;
|
||||
|
@ -227,7 +226,7 @@ void ForvoArticleRequest::requestFinished( QNetworkReply * r )
|
|||
QString( tr( "XML parse error: %1 at %2,%3" ).arg( errorStr ).arg( errorLine ).arg( errorColumn ) ) );
|
||||
}
|
||||
else {
|
||||
// GD_DPRINTF( "%s\n", dd.toByteArray().data() );
|
||||
// qDebug( "%s", dd.toByteArray().data() );
|
||||
|
||||
QDomNode items = dd.namedItem( "items" );
|
||||
|
||||
|
@ -330,7 +329,7 @@ void ForvoArticleRequest::requestFinished( QNetworkReply * r )
|
|||
setErrorString( text );
|
||||
}
|
||||
}
|
||||
GD_DPRINTF( "done.\n" );
|
||||
qDebug( "done." );
|
||||
}
|
||||
else {
|
||||
setErrorString( netReply->errorString() );
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "ufile.hh"
|
||||
#include "btreeidx.hh"
|
||||
#include "folding.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "utf8.hh"
|
||||
#include "wstring_qt.hh"
|
||||
#include "chunkedstorage.hh"
|
||||
|
@ -523,7 +522,7 @@ QString const & GlsDictionary::getDescription()
|
|||
}
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "GLS dictionary description reading failed: %s, error: %s\n", getName().c_str(), e.what() );
|
||||
qWarning( "GLS dictionary description reading failed: %s, error: %s", getName().c_str(), e.what() );
|
||||
}
|
||||
|
||||
if ( dictionaryDescription.isEmpty() ) {
|
||||
|
@ -554,14 +553,14 @@ void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
}
|
||||
|
||||
|
||||
gdDebug( "Gls: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "Gls: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Gls: Failed building full-text search index for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Gls: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( ftsIdxName.c_str() );
|
||||
}
|
||||
}
|
||||
|
@ -802,7 +801,7 @@ void GlsDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
text = Html::unescape( QString::fromStdString( articleStr ) );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Gls: Failed retrieving article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Gls: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1082,7 +1081,7 @@ void GlsResourceRequest::run()
|
|||
try {
|
||||
string n = dict.getContainingFolder().toStdString() + Utils::Fs::separator() + resourceName;
|
||||
|
||||
GD_DPRINTF( "gls resource name is %s\n", n.c_str() );
|
||||
qDebug( "gls resource name is %s", n.c_str() );
|
||||
|
||||
try {
|
||||
QMutexLocker _( &dataMutex );
|
||||
|
@ -1167,10 +1166,10 @@ void GlsResourceRequest::run()
|
|||
hasAnyData = true;
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "GLS: Failed loading resource \"%s\" for \"%s\", reason: %s\n",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
qWarning( "GLS: Failed loading resource \"%s\" for \"%s\", reason: %s",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
// Resource not loaded -- we don't set the hasAnyData flag then
|
||||
}
|
||||
|
||||
|
@ -1247,8 +1246,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
// Building the index
|
||||
initializing.indexingDictionary( Utf8::encode( scanner.getDictionaryName() ) );
|
||||
|
||||
gdDebug( "Gls: Building the index for dictionary: %s\n",
|
||||
QString::fromStdU32String( scanner.getDictionaryName() ).toUtf8().data() );
|
||||
qDebug( "Gls: Building the index for dictionary: %s",
|
||||
QString::fromStdU32String( scanner.getDictionaryName() ).toUtf8().data() );
|
||||
|
||||
File::Index idx( indexFile, QIODevice::WriteOnly );
|
||||
|
||||
|
@ -1350,7 +1349,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
// If there was a zip file, index it too
|
||||
|
||||
if ( zipFileName.size() ) {
|
||||
GD_DPRINTF( "Indexing zip file\n" );
|
||||
qDebug( "Indexing zip file" );
|
||||
|
||||
idxHeader.hasZipFile = 1;
|
||||
|
||||
|
@ -1415,7 +1414,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< GlsDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "GLS dictionary reading failed: %s:%u, error: %s\n", fileName.c_str(), atLine, e.what() );
|
||||
qWarning( "GLS dictionary reading failed: %s:%u, error: %s", fileName.c_str(), atLine, e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QFileInfo>
|
||||
#include <set>
|
||||
#include "gddebug.hh"
|
||||
#include "utils.hh"
|
||||
#include <QtConcurrentRun>
|
||||
|
||||
|
@ -271,10 +270,10 @@ void HunspellArticleRequest::run()
|
|||
}
|
||||
}
|
||||
catch ( Iconv::Ex & e ) {
|
||||
gdWarning( "Hunspell: charset conversion error, no processing's done: %s\n", e.what() );
|
||||
qWarning( "Hunspell: charset conversion error, no processing's done: %s", e.what() );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Hunspell: error: %s\n", e.what() );
|
||||
qWarning( "Hunspell: error: %s", e.what() );
|
||||
}
|
||||
|
||||
finish();
|
||||
|
@ -396,7 +395,7 @@ QList< wstring > suggest( wstring & word, QMutex & hunspellMutex, Hunspell & hun
|
|||
suggestion.chop( suggestion.length() - n );
|
||||
}
|
||||
|
||||
GD_DPRINTF( ">>>Sugg: %s\n", suggestion.toLocal8Bit().data() );
|
||||
qDebug( ">>>Sugg: %s", suggestion.toLocal8Bit().data() );
|
||||
|
||||
auto match = cutStem.match( suggestion.trimmed() );
|
||||
if ( match.hasMatch() ) {
|
||||
|
@ -411,7 +410,7 @@ QList< wstring > suggest( wstring & word, QMutex & hunspellMutex, Hunspell & hun
|
|||
}
|
||||
}
|
||||
catch ( Iconv::Ex & e ) {
|
||||
gdWarning( "Hunspell: charset conversion error, no processing's done: %s\n", e.what() );
|
||||
qWarning( "Hunspell: charset conversion error, no processing's done: %s", e.what() );
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -493,7 +492,7 @@ void HunspellPrefixMatchRequest::run()
|
|||
}
|
||||
}
|
||||
catch ( Iconv::Ex & e ) {
|
||||
gdWarning( "Hunspell: charset conversion error, no processing's done: %s\n", e.what() );
|
||||
qWarning( "Hunspell: charset conversion error, no processing's done: %s", e.what() );
|
||||
}
|
||||
|
||||
finish();
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "dict/forvo.hh"
|
||||
#include "dict/programs.hh"
|
||||
#include "dict/voiceengines.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "dict/xdxf.hh"
|
||||
#include "dict/sdict.hh"
|
||||
#include "dict/aard.hh"
|
||||
|
@ -281,7 +280,7 @@ void loadDictionaries( QWidget * parent,
|
|||
addDicts( DictServer::makeDictionaries( cfg.dictServers ) );
|
||||
|
||||
|
||||
GD_DPRINTF( "Load done\n" );
|
||||
qDebug( "Load done" );
|
||||
|
||||
// Remove any stale index files
|
||||
|
||||
|
@ -291,12 +290,12 @@ void loadDictionaries( QWidget * parent,
|
|||
for ( unsigned x = dictionaries.size(); x--; ) {
|
||||
ret = ids.insert( dictionaries[ x ]->getId() );
|
||||
if ( !ret.second ) {
|
||||
gdWarning( R"(Duplicate dictionary ID found: ID=%s, name="%s", path="%s")",
|
||||
dictionaries[ x ]->getId().c_str(),
|
||||
dictionaries[ x ]->getName().c_str(),
|
||||
dictionaries[ x ]->getDictionaryFilenames().empty() ?
|
||||
"" :
|
||||
dictionaries[ x ]->getDictionaryFilenames()[ 0 ].c_str() );
|
||||
qWarning( R"(Duplicate dictionary ID found: ID=%s, name="%s", path="%s")",
|
||||
dictionaries[ x ]->getId().c_str(),
|
||||
dictionaries[ x ]->getName().c_str(),
|
||||
dictionaries[ x ]->getDictionaryFilenames().empty() ?
|
||||
"" :
|
||||
dictionaries[ x ]->getDictionaryFilenames()[ 0 ].c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "btreeidx.hh"
|
||||
|
||||
#include "audiolink.hh"
|
||||
#include "gddebug.hh"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
@ -464,13 +463,13 @@ sptr< Dictionary::DataRequest > LsaDictionary::getResource( string const & name
|
|||
long result = ov_read( &vf, ptr, left, 0, 2, 1, &bitstream );
|
||||
|
||||
if ( result <= 0 ) {
|
||||
gdWarning( "Failed to read Vorbis data (code = %ld)\n", result );
|
||||
qWarning( "Failed to read Vorbis data (code = %ld)", result );
|
||||
memset( ptr, 0, left );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( result > left ) {
|
||||
GD_FDPRINTF( stderr, "Warning: Vorbis decode returned more data than requested.\n" );
|
||||
qWarning( "Warning: Vorbis decode returned more data than requested." );
|
||||
|
||||
result = left;
|
||||
}
|
||||
|
@ -539,7 +538,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) {
|
||||
// Building the index
|
||||
|
||||
gdDebug( "Lsa: Building the index for dictionary: %s\n", i->c_str() );
|
||||
qDebug( "Lsa: Building the index for dictionary: %s", i->c_str() );
|
||||
|
||||
initializing.indexingDictionary( Utils::Fs::basename( *i ) );
|
||||
|
||||
|
@ -559,7 +558,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
/// XXX handle big-endian machines here!
|
||||
auto entriesCount = f.read< uint32_t >();
|
||||
|
||||
GD_DPRINTF( "%s: %u entries\n", i->c_str(), entriesCount );
|
||||
qDebug( "%s: %u entries", i->c_str(), entriesCount );
|
||||
|
||||
idxHeader.soundsCount = entriesCount;
|
||||
|
||||
|
@ -574,7 +573,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
// Remove the extension, no need for that in the index
|
||||
e.name = stripExtension( e.name );
|
||||
|
||||
GD_DPRINTF( "Read filename %s (%u at %u)<\n", e.name.c_str(), e.samplesLength, e.samplesOffset );
|
||||
qDebug( "Read filename %s (%u at %u)<", e.name.c_str(), e.samplesLength, e.samplesOffset );
|
||||
|
||||
// Insert new entry into an index
|
||||
|
||||
|
@ -613,7 +612,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< LsaDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Lingvo's LSA reading failed: %s, error: %s\n", i->c_str(), e.what() );
|
||||
qWarning( "Lingvo's LSA reading failed: %s, error: %s", i->c_str(), e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include <QtCore5Compat/QTextCodec>
|
||||
|
||||
#include "decompress.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "ripemd.hh"
|
||||
#include "utils.hh"
|
||||
#include "htmlescape.hh"
|
||||
|
@ -118,7 +117,7 @@ bool MdictParser::open( const char * filename )
|
|||
filename_ = QString::fromUtf8( filename );
|
||||
file_ = new QFile( filename_ );
|
||||
|
||||
gdDebug( "MdictParser: open %s", filename );
|
||||
qDebug( "MdictParser: open %s", filename );
|
||||
|
||||
if ( file_.isNull() || !file_->exists() ) {
|
||||
return false;
|
||||
|
@ -233,7 +232,7 @@ bool MdictParser::parseCompressedBlock( qint64 compressedBlockSize,
|
|||
case 0x00000000:
|
||||
// No compression
|
||||
if ( !checkAdler32( buf, size, checksum ) ) {
|
||||
gdWarning( "MDict: parseCompressedBlock: plain: checksum not match" );
|
||||
qWarning( "MDict: parseCompressedBlock: plain: checksum not match" );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -248,13 +247,13 @@ bool MdictParser::parseCompressedBlock( qint64 compressedBlockSize,
|
|||
result = lzo1x_decompress_safe( (const uchar *)buf, size, (uchar *)decompressedBlock.data(), &blockSize, NULL );
|
||||
|
||||
if ( result != LZO_E_OK || blockSize != (lzo_uint)decompressedBlockSize ) {
|
||||
gdWarning( "MDict: parseCompressedBlock: decompression failed" );
|
||||
qWarning( "MDict: parseCompressedBlock: decompression failed" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( checksum
|
||||
!= lzo_adler32( lzo_adler32( 0, NULL, 0 ), (const uchar *)decompressedBlock.constData(), blockSize ) ) {
|
||||
gdWarning( "MDict: parseCompressedBlock: lzo: checksum does not match" );
|
||||
qWarning( "MDict: parseCompressedBlock: lzo: checksum does not match" );
|
||||
return false;
|
||||
}
|
||||
} break;
|
||||
|
@ -263,12 +262,12 @@ bool MdictParser::parseCompressedBlock( qint64 compressedBlockSize,
|
|||
// zlib compression
|
||||
decompressedBlock = zlibDecompress( buf, size, checksum );
|
||||
if ( decompressedBlock.isEmpty() ) {
|
||||
gdWarning( "MDict: parseCompressedBlock: zlib: failed to decompress or checksum does not match" );
|
||||
qWarning( "MDict: parseCompressedBlock: zlib: failed to decompress or checksum does not match" );
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
gdWarning( "MDict: parseCompressedBlock: unknown type" );
|
||||
qWarning( "MDict: parseCompressedBlock: unknown type" );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -320,7 +319,7 @@ bool MdictParser::readHeader( QDataStream & in )
|
|||
in.setByteOrder( QDataStream::LittleEndian );
|
||||
in >> checksum;
|
||||
if ( !checkAdler32( headerTextUtf16.constData(), headerTextUtf16.size(), checksum ) ) {
|
||||
gdWarning( "MDict: readHeader: checksum does not match" );
|
||||
qWarning( "MDict: readHeader: checksum does not match" );
|
||||
return false;
|
||||
}
|
||||
headerTextUtf16.clear();
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "wstring.hh"
|
||||
#include "wstring_qt.hh"
|
||||
#include "chunkedstorage.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "langcoder.hh"
|
||||
#include "audiolink.hh"
|
||||
#include "ex.hh"
|
||||
|
@ -448,7 +447,7 @@ void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
// return;
|
||||
|
||||
|
||||
gdDebug( "MDict: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
qDebug( "MDict: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
auto _dict = std::make_shared< MdxDictionary >( this->getId(), idxFileName, this->getDictionaryFilenames() );
|
||||
|
@ -459,7 +458,7 @@ void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "MDict: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
qWarning( "MDict: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( ftsIdxName.c_str() );
|
||||
}
|
||||
}
|
||||
|
@ -474,7 +473,7 @@ void MdxDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
text = Html::unescape( QString::fromUtf8( articleText.data(), articleText.size() ) );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "MDict: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
qWarning( "MDict: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1122,7 +1121,7 @@ QString MdxDictionary::getCachedFileName( QString filename )
|
|||
QFileInfo info( cacheDirName );
|
||||
if ( !info.exists() || !info.isDir() ) {
|
||||
if ( !dir.mkdir( cacheDirName ) ) {
|
||||
gdWarning( "Mdx: can't create cache directory \"%s\"", cacheDirName.toUtf8().data() );
|
||||
qWarning( "Mdx: can't create cache directory \"%s\"", cacheDirName.toUtf8().data() );
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
@ -1140,7 +1139,7 @@ QString MdxDictionary::getCachedFileName( QString filename )
|
|||
QFileInfo dirInfo( dirName );
|
||||
if ( !dirInfo.exists() ) {
|
||||
if ( !dir.mkdir( dirName ) ) {
|
||||
gdWarning( "Mdx: can't create cache directory \"%s\"", dirName.toUtf8().data() );
|
||||
qWarning( "Mdx: can't create cache directory \"%s\"", dirName.toUtf8().data() );
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
@ -1155,7 +1154,7 @@ QString MdxDictionary::getCachedFileName( QString filename )
|
|||
}
|
||||
QFile f( fullName );
|
||||
if ( !f.open( QFile::WriteOnly ) ) {
|
||||
gdWarning( R"(Mdx: file "%s" creating error: "%s")", fullName.toUtf8().data(), f.errorString().toUtf8().data() );
|
||||
qWarning( R"(Mdx: file "%s" creating error: "%s")", fullName.toUtf8().data(), f.errorString().toUtf8().data() );
|
||||
return QString();
|
||||
}
|
||||
gd::wstring resourceName = filename.toStdU32String();
|
||||
|
@ -1195,7 +1194,7 @@ QString MdxDictionary::getCachedFileName( QString filename )
|
|||
f.close();
|
||||
|
||||
if ( n < (qint64)data.size() ) {
|
||||
gdWarning( R"(Mdx: file "%s" writing error: "%s")", fullName.toUtf8().data(), f.errorString().toUtf8().data() );
|
||||
qWarning( R"(Mdx: file "%s" writing error: "%s")", fullName.toUtf8().data(), f.errorString().toUtf8().data() );
|
||||
return QString();
|
||||
}
|
||||
return fullName;
|
||||
|
@ -1343,7 +1342,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( dictFiles, indexFile ) ) {
|
||||
// Building the index
|
||||
|
||||
gdDebug( "MDict: Building the index for dictionary: %s\n", fileName.c_str() );
|
||||
qDebug( "MDict: Building the index for dictionary: %s", fileName.c_str() );
|
||||
|
||||
MdictParser parser;
|
||||
list< sptr< MdictParser > > mddParsers;
|
||||
|
@ -1359,7 +1358,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
if ( File::exists( *mddIter ) ) {
|
||||
sptr< MdictParser > mddParser = std::make_shared< MdictParser >();
|
||||
if ( !mddParser->open( mddIter->c_str() ) ) {
|
||||
gdWarning( "Broken mdd (resource) file: %s\n", mddIter->c_str() );
|
||||
qWarning( "Broken mdd (resource) file: %s", mddIter->c_str() );
|
||||
continue;
|
||||
}
|
||||
mddParsers.push_back( mddParser );
|
||||
|
@ -1434,7 +1433,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
// Finish with the chunks
|
||||
idxHeader.chunksOffset = chunks.finish();
|
||||
|
||||
GD_DPRINTF( "Writing index...\n" );
|
||||
qDebug( "Writing index..." );
|
||||
|
||||
// Good. Now build the index
|
||||
IndexInfo idxInfo = BtreeIndexing::buildIndex( indexedWords, idx );
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <QtXml>
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include "gddebug.hh"
|
||||
#include "audiolink.hh"
|
||||
#include "langcoder.hh"
|
||||
#include "utils.hh"
|
||||
|
@ -156,7 +155,7 @@ MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str,
|
|||
QNetworkAccessManager & mgr ):
|
||||
isCancelling( false )
|
||||
{
|
||||
GD_DPRINTF( "wiki request begin\n" );
|
||||
qDebug( "wiki request begin" );
|
||||
QUrl reqUrl( url + "/api.php?action=query&list=allpages&aplimit=40&format=xml" );
|
||||
|
||||
GlobalBroadcaster::instance()->addWhitelist( reqUrl.host() );
|
||||
|
@ -180,7 +179,7 @@ MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str,
|
|||
|
||||
MediaWikiWordSearchRequest::~MediaWikiWordSearchRequest()
|
||||
{
|
||||
GD_DPRINTF( "request end\n" );
|
||||
qDebug( "request end" );
|
||||
}
|
||||
|
||||
void MediaWikiWordSearchRequest::cancel()
|
||||
|
@ -194,7 +193,7 @@ void MediaWikiWordSearchRequest::cancel()
|
|||
|
||||
finish();
|
||||
|
||||
GD_DPRINTF( "cancel the request" );
|
||||
qDebug( "cancel the request" );
|
||||
}
|
||||
|
||||
void MediaWikiWordSearchRequest::downloadFinished()
|
||||
|
@ -227,7 +226,7 @@ void MediaWikiWordSearchRequest::downloadFinished()
|
|||
}
|
||||
}
|
||||
}
|
||||
GD_DPRINTF( "done.\n" );
|
||||
qDebug( "done." );
|
||||
}
|
||||
else {
|
||||
setErrorString( netReply->errorString() );
|
||||
|
@ -258,11 +257,11 @@ public:
|
|||
|
||||
QDomElement const sectionsElement = parseNode.firstChildElement( "sections" );
|
||||
if ( sectionsElement.isNull() ) {
|
||||
gdWarning( "MediaWiki: empty table of contents and missing sections element." );
|
||||
qWarning( "MediaWiki: empty table of contents and missing sections element." );
|
||||
return;
|
||||
}
|
||||
|
||||
gdDebug( "MediaWiki: generating table of contents from the sections element." );
|
||||
qDebug( "MediaWiki: generating table of contents from the sections element." );
|
||||
MediaWikiSectionsParser parser;
|
||||
parser.generateTableOfContents( sectionsElement );
|
||||
articleString.replace( emptyTocPos, emptyTocIndicator.size(), parser.tableOfContents );
|
||||
|
@ -343,17 +342,17 @@ bool MediaWikiSectionsParser::addListLevel( QString const & levelString )
|
|||
int const level = levelString.toInt( &convertedToInt );
|
||||
|
||||
if ( !convertedToInt ) {
|
||||
gdWarning( "MediaWiki: sections level is not an integer: %s", levelString.toUtf8().constData() );
|
||||
qWarning( "MediaWiki: sections level is not an integer: %s", levelString.toUtf8().constData() );
|
||||
return false;
|
||||
}
|
||||
if ( level <= 0 ) {
|
||||
gdWarning( "MediaWiki: unsupported nonpositive sections level: %s", levelString.toUtf8().constData() );
|
||||
qWarning( "MediaWiki: unsupported nonpositive sections level: %s", levelString.toUtf8().constData() );
|
||||
return false;
|
||||
}
|
||||
if ( level > previousLevel + 1 ) {
|
||||
gdWarning( "MediaWiki: unsupported sections level increase by more than one: from %d to %s",
|
||||
previousLevel,
|
||||
levelString.toUtf8().constData() );
|
||||
qWarning( "MediaWiki: unsupported sections level increase by more than one: from %d to %s",
|
||||
previousLevel,
|
||||
levelString.toUtf8().constData() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -466,7 +465,7 @@ MediaWikiArticleRequest::MediaWikiArticleRequest( wstring const & str,
|
|||
|
||||
void MediaWikiArticleRequest::addQuery( QNetworkAccessManager & mgr, wstring const & str )
|
||||
{
|
||||
gdDebug( "MediaWiki: requesting article %s\n", QString::fromStdU32String( str ).toUtf8().data() );
|
||||
qDebug( "MediaWiki: requesting article %s", QString::fromStdU32String( str ).toUtf8().data() );
|
||||
|
||||
QUrl reqUrl( url + "/api.php?action=parse&prop=text|revid|sections&format=xml&redirects" );
|
||||
|
||||
|
@ -490,7 +489,7 @@ void MediaWikiArticleRequest::addQuery( QNetworkAccessManager & mgr, wstring con
|
|||
|
||||
void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
||||
{
|
||||
GD_DPRINTF( "Finished.\n" );
|
||||
qDebug( "Finished." );
|
||||
|
||||
if ( isFinished() ) { // Was cancelled
|
||||
return;
|
||||
|
@ -693,7 +692,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
|||
}
|
||||
}
|
||||
}
|
||||
GD_DPRINTF( "done.\n" );
|
||||
qDebug( "done." );
|
||||
}
|
||||
else {
|
||||
setErrorString( netReply->errorString() );
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "decompress.hh"
|
||||
#include "folding.hh"
|
||||
#include "ftshelpers.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "htmlescape.hh"
|
||||
#include "langcoder.hh"
|
||||
#include "sdict.hh"
|
||||
|
@ -223,7 +222,7 @@ void SdictDictionary::loadIcon() noexcept
|
|||
|
||||
string SdictDictionary::convert( string const & in )
|
||||
{
|
||||
// GD_DPRINTF( "Source>>>>>>>>>>: %s\n\n\n", in.c_str() );
|
||||
// qDebug( "Source>>>>>>>>>>: %s\n\n", in.c_str() );
|
||||
|
||||
string inConverted;
|
||||
|
||||
|
@ -374,14 +373,14 @@ void SdictDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
}
|
||||
|
||||
|
||||
gdDebug( "SDict: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "SDict: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "SDict: Failed building full-text search index for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "SDict: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( ftsIdxName.c_str() );
|
||||
}
|
||||
}
|
||||
|
@ -402,7 +401,7 @@ void SdictDictionary::getArticleText( uint32_t articleAddress, QString & headwor
|
|||
}
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "SDict: Failed retrieving article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "SDict: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,7 +525,7 @@ void SdictArticleRequest::run()
|
|||
articlesIncluded.insert( x.articleOffset );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "SDict: Failed loading article from \"%s\", reason: %s\n", dict.getName().c_str(), ex.what() );
|
||||
qWarning( "SDict: Failed loading article from \"%s\", reason: %s", dict.getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -637,7 +636,7 @@ QString const & SdictDictionary::getDescription()
|
|||
QObject::tr( "Version: %1%2" ).arg( QString::fromUtf8( str.c_str(), str.size() ) ).arg( "\n\n" );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "SDict: Failed description reading for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "SDict: Failed description reading for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
|
||||
if ( dictionaryDescription.isEmpty() ) {
|
||||
|
@ -673,7 +672,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
|
||||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) {
|
||||
try {
|
||||
gdDebug( "SDict: Building the index for dictionary: %s\n", fileName.c_str() );
|
||||
qDebug( "SDict: Building the index for dictionary: %s", fileName.c_str() );
|
||||
|
||||
File::Index df( fileName, QIODevice::ReadOnly );
|
||||
|
||||
|
@ -681,7 +680,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
|
||||
df.read( &dictHeader, sizeof( dictHeader ) );
|
||||
if ( strncmp( dictHeader.signature, "sdct", 4 ) ) {
|
||||
gdWarning( "File \"%s\" is not valid SDictionary file", fileName.c_str() );
|
||||
qWarning( "File \"%s\" is not valid SDictionary file", fileName.c_str() );
|
||||
continue;
|
||||
}
|
||||
int compression = dictHeader.compression & 0x0F;
|
||||
|
@ -781,11 +780,11 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
idx.write( &idxHeader, sizeof( idxHeader ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Sdictionary dictionary indexing failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "Sdictionary dictionary indexing failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
continue;
|
||||
}
|
||||
catch ( ... ) {
|
||||
qWarning( "Sdictionary dictionary indexing failed\n" );
|
||||
qWarning( "Sdictionary dictionary indexing failed" );
|
||||
continue;
|
||||
}
|
||||
} // if need to rebuild
|
||||
|
@ -793,7 +792,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< SdictDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Sdictionary dictionary initializing failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "Sdictionary dictionary initializing failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
}
|
||||
}
|
||||
return dictionaries;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "btreeidx.hh"
|
||||
|
||||
#include "folding.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "utf8.hh"
|
||||
#include "decompress.hh"
|
||||
#include "langcoder.hh"
|
||||
|
@ -936,7 +935,7 @@ void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
}
|
||||
|
||||
|
||||
gdDebug( "Slob: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "Slob: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
const auto slob_dic = std::make_unique< SlobDictionary >( getId(), idxFileName, getDictionaryFilenames() );
|
||||
|
@ -944,7 +943,7 @@ void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Slob: Failed building full-text search index for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Slob: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( ftsIdxName.c_str() );
|
||||
}
|
||||
}
|
||||
|
@ -974,7 +973,7 @@ void SlobDictionary::getArticleText( uint32_t articleAddress, QString & headword
|
|||
}
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Slob: Failed retrieving article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Slob: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1222,10 +1221,10 @@ void SlobResourceRequest::run()
|
|||
hasAnyData = true;
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "SLOB: Failed loading resource \"%s\" from \"%s\", reason: %s\n",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
qWarning( "SLOB: Failed loading resource \"%s\" from \"%s\", reason: %s",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
// Resource not loaded -- we don't set the hasAnyData flag then
|
||||
}
|
||||
|
||||
|
@ -1268,7 +1267,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) {
|
||||
SlobFile sf;
|
||||
|
||||
gdDebug( "Slob: Building the index for dictionary: %s\n", fileName.c_str() );
|
||||
qDebug( "Slob: Building the index for dictionary: %s", fileName.c_str() );
|
||||
|
||||
sf.open( firstName );
|
||||
|
||||
|
@ -1362,11 +1361,11 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< SlobDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Slob dictionary initializing failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "Slob dictionary initializing failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
continue;
|
||||
}
|
||||
catch ( ... ) {
|
||||
qWarning( "Slob dictionary initializing failed\n" );
|
||||
qWarning( "Slob dictionary initializing failed" );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -524,8 +524,8 @@ bool MediaWikisModel::setData( QModelIndex const & index, const QVariant & value
|
|||
}
|
||||
|
||||
if ( role == Qt::CheckStateRole && !index.column() ) {
|
||||
//GD_DPRINTF( "type = %d\n", (int)value.type() );
|
||||
//GD_DPRINTF( "value = %d\n", (int)value.toInt() );
|
||||
//qDebug( "type = %d", (int)value.type() );
|
||||
//qDebug( "value = %d", (int)value.toInt() );
|
||||
|
||||
// XXX it seems to be always passing Int( 2 ) as a value, so we just toggle
|
||||
mediawikis[ index.row() ].enabled = !mediawikis[ index.row() ].enabled;
|
||||
|
@ -713,8 +713,8 @@ bool WebSitesModel::setData( QModelIndex const & index, const QVariant & value,
|
|||
}
|
||||
|
||||
if ( role == Qt::CheckStateRole && !index.column() ) {
|
||||
//GD_DPRINTF( "type = %d\n", (int)value.type() );
|
||||
//GD_DPRINTF( "value = %d\n", (int)value.toInt() );
|
||||
//qDebug( "type = %d", (int)value.type() );
|
||||
//qDebug( "value = %d", (int)value.toInt() );
|
||||
|
||||
// XXX it seems to be always passing Int( 2 ) as a value, so we just toggle
|
||||
webSites[ index.row() ].enabled = !webSites[ index.row() ].enabled;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "xdxf2html.hh"
|
||||
#include "htmlescape.hh"
|
||||
#include "langcoder.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "filetype.hh"
|
||||
#include "indexedzip.hh"
|
||||
#include "tiff.hh"
|
||||
|
@ -931,9 +930,7 @@ void StardictDictionary::loadArticle( uint32_t address, string & headword, strin
|
|||
entrySize = size;
|
||||
}
|
||||
else if ( !size ) {
|
||||
gdWarning( "Stardict: short entry for the word %s encountered in \"%s\".\n",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
qWarning( "Stardict: short entry for the word %s encountered in \"%s\".", headword.c_str(), getName().c_str() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -946,9 +943,9 @@ void StardictDictionary::loadArticle( uint32_t address, string & headword, strin
|
|||
}
|
||||
|
||||
if ( size < entrySize ) {
|
||||
gdWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -966,9 +963,9 @@ void StardictDictionary::loadArticle( uint32_t address, string & headword, strin
|
|||
|
||||
if ( !entrySizeKnown ) {
|
||||
if ( size < sizeof( uint32_t ) ) {
|
||||
gdWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -981,9 +978,9 @@ void StardictDictionary::loadArticle( uint32_t address, string & headword, strin
|
|||
}
|
||||
|
||||
if ( size < entrySize ) {
|
||||
gdWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -993,10 +990,10 @@ void StardictDictionary::loadArticle( uint32_t address, string & headword, strin
|
|||
size -= entrySize;
|
||||
}
|
||||
else {
|
||||
gdWarning( "Stardict: non-alpha entry type 0x%x for the word %s encountered in \"%s\".\n",
|
||||
type,
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
qWarning( "Stardict: non-alpha entry type 0x%x for the word %s encountered in \"%s\".",
|
||||
type,
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1009,9 +1006,9 @@ void StardictDictionary::loadArticle( uint32_t address, string & headword, strin
|
|||
size_t len = strlen( ptr + 1 );
|
||||
|
||||
if ( size < len + 2 ) {
|
||||
gdWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1023,9 +1020,9 @@ void StardictDictionary::loadArticle( uint32_t address, string & headword, strin
|
|||
else if ( isupper( *ptr ) ) {
|
||||
// An entry which havs its size before contents
|
||||
if ( size < sizeof( uint32_t ) + 1 ) {
|
||||
gdWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1036,9 +1033,9 @@ void StardictDictionary::loadArticle( uint32_t address, string & headword, strin
|
|||
entrySize = ntohl( entrySize );
|
||||
|
||||
if ( size < sizeof( uint32_t ) + 1 + entrySize ) {
|
||||
gdWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".",
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1048,10 +1045,10 @@ void StardictDictionary::loadArticle( uint32_t address, string & headword, strin
|
|||
size -= sizeof( uint32_t ) + 1 + entrySize;
|
||||
}
|
||||
else {
|
||||
gdWarning( "Stardict: non-alpha entry type 0x%x for the word %s encountered in \"%s\".\n",
|
||||
(unsigned)*ptr,
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
qWarning( "Stardict: non-alpha entry type 0x%x for the word %s encountered in \"%s\".",
|
||||
(unsigned)*ptr,
|
||||
headword.c_str(),
|
||||
getName().c_str() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1126,16 +1123,14 @@ void StardictDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
}
|
||||
|
||||
|
||||
gdDebug( "Stardict: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "Stardict: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Stardict: Failed building full-text search index for \"%s\", reason: %s\n",
|
||||
getName().c_str(),
|
||||
ex.what() );
|
||||
qWarning( "Stardict: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( ftsIdxName.c_str() );
|
||||
}
|
||||
}
|
||||
|
@ -1151,7 +1146,7 @@ void StardictDictionary::getArticleText( uint32_t articleAddress, QString & head
|
|||
text = Html::unescape( QString::fromStdString( articleStr ) );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Stardict: Failed retrieving article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Stardict: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1564,7 +1559,7 @@ void StardictResourceRequest::run()
|
|||
string n =
|
||||
dict.getContainingFolder().toStdString() + Utils::Fs::separator() + "res" + Utils::Fs::separator() + resourceName;
|
||||
|
||||
GD_DPRINTF( "startdict resource name is %s\n", n.c_str() );
|
||||
qDebug( "startdict resource name is %s", n.c_str() );
|
||||
|
||||
try {
|
||||
QMutexLocker _( &dataMutex );
|
||||
|
@ -1641,10 +1636,10 @@ void StardictResourceRequest::run()
|
|||
hasAnyData = true;
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Stardict: Failed loading resource \"%s\" for \"%s\", reason: %s\n",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
qWarning( "Stardict: Failed loading resource \"%s\" for \"%s\", reason: %s",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
// Resource not loaded -- we don't set the hasAnyData flag then
|
||||
}
|
||||
catch ( ... ) {
|
||||
|
@ -1726,7 +1721,7 @@ static void handleIdxSynFile( string const & fileName,
|
|||
size_t wordLen = strlen( ptr );
|
||||
|
||||
if ( ptr + wordLen + 1 + ( isSynFile ? sizeof( uint32_t ) : sizeof( uint32_t ) * 2 ) > &image.back() ) {
|
||||
GD_FDPRINTF( stderr, "Warning: sudden end of file %s\n", fileName.c_str() );
|
||||
qWarning( "Warning: sudden end of file %s", fileName.c_str() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1816,7 +1811,7 @@ static void handleIdxSynFile( string const & fileName,
|
|||
}
|
||||
}
|
||||
|
||||
GD_DPRINTF( "%u entires made\n", (unsigned)indexedWords.size() );
|
||||
qDebug( "%u entires made", (unsigned)indexedWords.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1868,7 +1863,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
|
||||
Ifo ifo( QString::fromStdString( fileName ) );
|
||||
|
||||
gdDebug( "Stardict: Building the index for dictionary: %s\n", ifo.bookname.c_str() );
|
||||
qDebug( "Stardict: Building the index for dictionary: %s", ifo.bookname.c_str() );
|
||||
|
||||
if ( ifo.idxoffsetbits == 64 ) {
|
||||
throw ex64BitsNotSupported();
|
||||
|
@ -1880,20 +1875,20 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
|
||||
if ( synFileName.empty() ) {
|
||||
if ( ifo.synwordcount ) {
|
||||
GD_DPRINTF(
|
||||
qDebug(
|
||||
"Warning: dictionary has synwordcount specified, but no "
|
||||
"corresponding .syn file was found\n" );
|
||||
ifo.synwordcount = 0; // Pretend it wasn't there
|
||||
}
|
||||
}
|
||||
else if ( !ifo.synwordcount ) {
|
||||
GD_DPRINTF( "Warning: ignoring .syn file %s, since there's no synwordcount in .ifo specified\n",
|
||||
synFileName.c_str() );
|
||||
qDebug( "Warning: ignoring .syn file %s, since there's no synwordcount in .ifo specified",
|
||||
synFileName.c_str() );
|
||||
}
|
||||
|
||||
|
||||
GD_DPRINTF( "bookname = %s\n", ifo.bookname.c_str() );
|
||||
GD_DPRINTF( "wordcount = %u\n", ifo.wordcount );
|
||||
qDebug( "bookname = %s", ifo.bookname.c_str() );
|
||||
qDebug( "wordcount = %u", ifo.wordcount );
|
||||
|
||||
initializing.indexingDictionary( ifo.bookname );
|
||||
|
||||
|
@ -1978,7 +1973,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
// If there was a zip file, index it too
|
||||
|
||||
if ( zipFileName.size() ) {
|
||||
GD_DPRINTF( "Indexing zip file\n" );
|
||||
qDebug( "Indexing zip file" );
|
||||
|
||||
idxHeader.hasZipFile = 1;
|
||||
|
||||
|
@ -2017,7 +2012,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< StardictDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Stardict dictionary initializing failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "Stardict dictionary initializing failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <QCoreApplication>
|
||||
#include <opencc/opencc.h>
|
||||
#include "folding.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "transliteration.hh"
|
||||
#include "utf8.hh"
|
||||
|
||||
|
@ -42,18 +41,18 @@ CharacterConversionDictionary::CharacterConversionDictionary( std::string const
|
|||
// #ifdef Q_OS_MAC
|
||||
converter = opencc_open( openccConfig.toLocal8Bit().constData() );
|
||||
if ( converter == reinterpret_cast< opencc_t >( -1 ) ) {
|
||||
gdWarning( "CharacterConversionDictionary: failed to initialize OpenCC from config %s: %s\n",
|
||||
openccConfig.toLocal8Bit().constData(),
|
||||
opencc_error() );
|
||||
qWarning( "CharacterConversionDictionary: failed to initialize OpenCC from config %s: %s",
|
||||
openccConfig.toLocal8Bit().constData(),
|
||||
opencc_error() );
|
||||
}
|
||||
// #else
|
||||
// converter = new opencc::SimpleConverter( openccConfig.toLocal8Bit().constData() );
|
||||
// #endif
|
||||
}
|
||||
catch ( std::runtime_error & e ) {
|
||||
gdWarning( "CharacterConversionDictionary: failed to initialize OpenCC from config %s: %s\n",
|
||||
openccConfig.toLocal8Bit().constData(),
|
||||
e.what() );
|
||||
qWarning( "CharacterConversionDictionary: failed to initialize OpenCC from config %s: %s",
|
||||
openccConfig.toLocal8Bit().constData(),
|
||||
e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +87,7 @@ std::vector< gd::wstring > CharacterConversionDictionary::getAlternateWritings(
|
|||
opencc_convert_utf8_free( tmp );
|
||||
}
|
||||
else {
|
||||
gdWarning( "OpenCC: conversion failed %s\n", opencc_error() );
|
||||
qWarning( "OpenCC: conversion failed %s", opencc_error() );
|
||||
}
|
||||
}
|
||||
// #else
|
||||
|
@ -97,7 +96,7 @@ std::vector< gd::wstring > CharacterConversionDictionary::getAlternateWritings(
|
|||
result = Utf8::decode( output );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "OpenCC: conversion failed %s\n", ex.what() );
|
||||
qWarning( "OpenCC: conversion failed %s", ex.what() );
|
||||
}
|
||||
|
||||
if ( !result.empty() && result != folded ) {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "transliteration.hh"
|
||||
#include "utf8.hh"
|
||||
#include "folding.hh"
|
||||
#include "gddebug.hh"
|
||||
|
||||
namespace Transliteration {
|
||||
|
||||
|
@ -61,7 +60,7 @@ sptr< Dictionary::WordSearchRequest > BaseTransliterationDictionary::findHeadwor
|
|||
|
||||
vector< wstring > alts = getAlternateWritings( str );
|
||||
|
||||
GD_DPRINTF( "alts = %u\n", (unsigned)alts.size() );
|
||||
qDebug( "alts = %u", (unsigned)alts.size() );
|
||||
|
||||
for ( const auto & alt : alts ) {
|
||||
result->getMatches().push_back( alt );
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "indexedzip.hh"
|
||||
#include "zipfile.hh"
|
||||
#include <zlib.h>
|
||||
#include "gddebug.hh"
|
||||
#include "utf8.hh"
|
||||
#include "iconv.hh"
|
||||
#include "wstring_qt.hh"
|
||||
|
@ -67,7 +66,7 @@ bool IndexedZip::loadFile( uint32_t offset, vector< char > & data )
|
|||
if ( !ZipFile::readLocalHeader( zip, header ) ) {
|
||||
vector< string > zipFileNames;
|
||||
zip.getFilenames( zipFileNames );
|
||||
GD_DPRINTF( "Failed to load header" );
|
||||
qDebug( "Failed to load header" );
|
||||
string filename;
|
||||
if ( zip.getCurrentFile() < zipFileNames.size() ) {
|
||||
filename = zipFileNames.at( zip.getCurrentFile() );
|
||||
|
@ -81,7 +80,7 @@ bool IndexedZip::loadFile( uint32_t offset, vector< char > & data )
|
|||
|
||||
switch ( header.compressionMethod ) {
|
||||
case ZipFile::Uncompressed:
|
||||
GD_DPRINTF( "Uncompressed" );
|
||||
qDebug( "Uncompressed" );
|
||||
data.resize( header.uncompressedSize );
|
||||
return (size_t)zip.read( &data.front(), data.size() ) == data.size();
|
||||
|
||||
|
@ -111,7 +110,7 @@ bool IndexedZip::loadFile( uint32_t offset, vector< char > & data )
|
|||
}
|
||||
|
||||
if ( inflate( &stream, Z_FINISH ) != Z_STREAM_END ) {
|
||||
GD_DPRINTF( "Not zstream end!" );
|
||||
qDebug( "Not zstream end!" );
|
||||
|
||||
data.clear();
|
||||
|
||||
|
@ -156,7 +155,7 @@ bool IndexedZip::indexFile( BtreeIndexing::IndexedWords & zipFileNames, quint32
|
|||
|
||||
while ( ZipFile::readNextEntry( zip, entry ) ) {
|
||||
if ( entry.compressionMethod == ZipFile::Unsupported ) {
|
||||
qWarning( "Zip warning: compression method unsupported -- skipping file \"%s\"\n", entry.fileName.data() );
|
||||
qWarning( "Zip warning: compression method unsupported -- skipping file \"%s\"", entry.fileName.data() );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <QTextCodec>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include "gddebug.hh"
|
||||
#include "globalbroadcaster.hh"
|
||||
#include "fmt/compile.h"
|
||||
|
||||
|
@ -300,9 +299,9 @@ void WebSiteArticleRequest::requestFinished( QNetworkReply * r )
|
|||
}
|
||||
else {
|
||||
if ( netReply->url().scheme() == "file" ) {
|
||||
gdWarning( "WebSites: Failed loading article from \"%s\", reason: %s\n",
|
||||
dictPtr->getName().c_str(),
|
||||
netReply->errorString().toUtf8().data() );
|
||||
qWarning( "WebSites: Failed loading article from \"%s\", reason: %s",
|
||||
dictPtr->getName().c_str(),
|
||||
netReply->errorString().toUtf8().data() );
|
||||
}
|
||||
else {
|
||||
setErrorString( netReply->errorString() );
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include <list>
|
||||
#include <wctype.h>
|
||||
#include <stdlib.h>
|
||||
#include "gddebug.hh"
|
||||
#include "xdxf2html.hh"
|
||||
#include "ufile.hh"
|
||||
#include "langcoder.hh"
|
||||
|
@ -377,14 +376,14 @@ void XdxfDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
}
|
||||
|
||||
|
||||
gdDebug( "Xdxf: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "Xdxf: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
|
||||
try {
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Xdxf: Failed building full-text search index for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Xdxf: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( ftsIdxName.c_str() );
|
||||
}
|
||||
}
|
||||
|
@ -398,7 +397,7 @@ void XdxfDictionary::getArticleText( uint32_t articleAddress, QString & headword
|
|||
text = Html::unescape( QString::fromStdString( articleStr ) );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Xdxf: Failed retrieving article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Xdxf: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -522,7 +521,7 @@ void XdxfArticleRequest::run()
|
|||
articlesIncluded.insert( x.articleOffset );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "XDXF: Failed loading article from \"%s\", reason: %s\n", dict.getName().c_str(), ex.what() );
|
||||
qWarning( "XDXF: Failed loading article from \"%s\", reason: %s", dict.getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -863,7 +862,7 @@ void indexArticle( GzippedFile & gzFile,
|
|||
|
||||
if ( words.empty() ) {
|
||||
// Nothing to index, this article didn't have any tags
|
||||
gdWarning( "No <k> tags found in an article at offset 0x%x, article skipped.\n", (unsigned)articleOffset );
|
||||
qWarning( "No <k> tags found in an article at offset 0x%x, article skipped.", (unsigned)articleOffset );
|
||||
}
|
||||
else {
|
||||
// Add an entry
|
||||
|
@ -883,7 +882,7 @@ void indexArticle( GzippedFile & gzFile,
|
|||
// Add also first header - it's needed for full-text search
|
||||
chunks.addToBlock( words.begin()->toUtf8().data(), words.begin()->toUtf8().length() + 1 );
|
||||
|
||||
// GD_DPRINTF( "%x: %s\n", articleOffset, words.begin()->toUtf8().data() );
|
||||
// qDebug( "%x: %s", articleOffset, words.begin()->toUtf8().data() );
|
||||
|
||||
// Add words to index
|
||||
|
||||
|
@ -958,7 +957,7 @@ void XdxfResourceRequest::run()
|
|||
|
||||
string n = dict.getContainingFolder().toStdString() + Utils::Fs::separator() + resourceName;
|
||||
|
||||
GD_DPRINTF( "xdxf resource name is %s\n", n.c_str() );
|
||||
qDebug( "xdxf resource name is %s", n.c_str() );
|
||||
|
||||
try {
|
||||
try {
|
||||
|
@ -1001,10 +1000,10 @@ void XdxfResourceRequest::run()
|
|||
hasAnyData = true;
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "XDXF: Failed loading resource \"%s\" for \"%s\", reason: %s\n",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
qWarning( "XDXF: Failed loading resource \"%s\" for \"%s\", reason: %s",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
// Resource not loaded -- we don't set the hasAnyData flag then
|
||||
}
|
||||
|
||||
|
@ -1058,7 +1057,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) {
|
||||
// Building the index
|
||||
|
||||
gdDebug( "Xdxf: Building the index for dictionary: %s\n", fileName.c_str() );
|
||||
qDebug( "Xdxf: Building the index for dictionary: %s", fileName.c_str() );
|
||||
|
||||
//initializing.indexingDictionary( nameFromFileName( dictFiles[ 0 ] ) );
|
||||
|
||||
|
@ -1147,7 +1146,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
chunks.addToBlock( n.data(), n.size() );
|
||||
}
|
||||
else {
|
||||
GD_DPRINTF( "Warning: duplicate full_name in %s\n", dictFiles[ 0 ].c_str() );
|
||||
qDebug( "Warning: duplicate full_name in %s", dictFiles[ 0 ].c_str() );
|
||||
}
|
||||
}
|
||||
else if ( stream.name() == u"description" ) {
|
||||
|
@ -1171,7 +1170,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
chunks.addToBlock( n.data(), n.size() );
|
||||
}
|
||||
else {
|
||||
GD_DPRINTF( "Warning: duplicate description in %s\n", dictFiles[ 0 ].c_str() );
|
||||
qDebug( "Warning: duplicate description in %s", dictFiles[ 0 ].c_str() );
|
||||
}
|
||||
}
|
||||
else if ( stream.name() == u"languages" ) {
|
||||
|
@ -1297,7 +1296,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
// If there was a zip file, index it too
|
||||
|
||||
if ( zipFileName.size() ) {
|
||||
GD_DPRINTF( "Indexing zip file\n" );
|
||||
qDebug( "Indexing zip file" );
|
||||
|
||||
idxHeader.hasZipFile = 1;
|
||||
|
||||
|
@ -1348,17 +1347,17 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
}
|
||||
|
||||
if ( stream.hasError() ) {
|
||||
gdWarning( "%s had a parse error %s at line %lu, and therefore was indexed only up to the point of error.",
|
||||
dictFiles[ 0 ].c_str(),
|
||||
stream.errorString().toUtf8().data(),
|
||||
(unsigned long)stream.lineNumber() );
|
||||
qWarning( "%s had a parse error %s at line %lu, and therefore was indexed only up to the point of error.",
|
||||
dictFiles[ 0 ].c_str(),
|
||||
stream.errorString().toUtf8().data(),
|
||||
(unsigned long)stream.lineNumber() );
|
||||
}
|
||||
}
|
||||
|
||||
dictionaries.push_back( std::make_shared< XdxfDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Xdxf dictionary initializing failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "Xdxf dictionary initializing failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "xdxf2html.hh"
|
||||
#include <QtXml>
|
||||
#include "gddebug.hh"
|
||||
#include "utf8.hh"
|
||||
#include "wstring_qt.hh"
|
||||
#include "folding.hh"
|
||||
|
@ -131,21 +130,21 @@ string convert( string const & in,
|
|||
|
||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 5, 0 ) )
|
||||
if ( !dd.setContent( QByteArray( in_data.c_str() ), false, &errorStr, &errorLine, &errorColumn ) ) {
|
||||
qWarning( "Xdxf2html error, xml parse failed: %s at %d,%d\n",
|
||||
qWarning( "Xdxf2html error, xml parse failed: %s at %d,%d",
|
||||
errorStr.toLocal8Bit().constData(),
|
||||
errorLine,
|
||||
errorColumn );
|
||||
gdWarning( "The input was: %s\n", in_data.c_str() );
|
||||
qWarning( "The input was: %s", in_data.c_str() );
|
||||
return in;
|
||||
}
|
||||
#else
|
||||
auto setContentResult = dd.setContent( QByteArray::fromStdString( in_data ) );
|
||||
if ( !setContentResult ) {
|
||||
qWarning( "Xdxf2html error, xml parse failed: %s at %lld,%lld\n",
|
||||
qWarning( "Xdxf2html error, xml parse failed: %s at %lld,%lld",
|
||||
setContentResult.errorMessage.toStdString().c_str(),
|
||||
setContentResult.errorLine,
|
||||
setContentResult.errorColumn );
|
||||
gdWarning( "The input was: %s\n", in_data.c_str() );
|
||||
qWarning( "The input was: %s", in_data.c_str() );
|
||||
return in;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "zim.hh"
|
||||
#include "btreeidx.hh"
|
||||
#include "folding.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "utf8.hh"
|
||||
#include "langcoder.hh"
|
||||
#include "filetype.hh"
|
||||
|
@ -284,7 +283,7 @@ void ZimDictionary::loadIcon() noexcept
|
|||
return;
|
||||
}
|
||||
catch ( zim::EntryNotFound & e ) {
|
||||
gdDebug( "ZIM icon not loaded for: %s", dictionaryName.c_str() );
|
||||
qDebug( "ZIM icon not loaded for: %s", dictionaryName.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,13 +485,13 @@ void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled )
|
|||
return;
|
||||
}
|
||||
|
||||
gdDebug( "Zim: Building the full-text index for dictionary: %s\n", getName().c_str() );
|
||||
qDebug( "Zim: Building the full-text index for dictionary: %s", getName().c_str() );
|
||||
try {
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Zim: Failed building full-text search index for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Zim: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
QFile::remove( ftsIdxName.c_str() );
|
||||
}
|
||||
}
|
||||
|
@ -507,7 +506,7 @@ void ZimDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
text = Html::unescape( QString::fromUtf8( articleText.data(), articleText.size() ) );
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Zim: Failed retrieving article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
|
||||
qWarning( "Zim: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -756,10 +755,10 @@ void ZimResourceRequest::run()
|
|||
hasAnyData = true;
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "ZIM: Failed loading resource \"%s\" from \"%s\", reason: %s\n",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
qWarning( "ZIM: Failed loading resource \"%s\" from \"%s\", reason: %s",
|
||||
resourceName.c_str(),
|
||||
dict.getName().c_str(),
|
||||
ex.what() );
|
||||
// Resource not loaded -- we don't set the hasAnyData flag then
|
||||
}
|
||||
|
||||
|
@ -811,7 +810,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
try {
|
||||
//only check zim file.
|
||||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) {
|
||||
gdDebug( "Zim: Building the index for dictionary: %s\n", fileName.c_str() );
|
||||
qDebug( "Zim: Building the index for dictionary: %s", fileName.c_str() );
|
||||
|
||||
unsigned articleCount = df.getArticleCount();
|
||||
unsigned wordCount = 0;
|
||||
|
@ -899,11 +898,11 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< ZimDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Zim dictionary initializing failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "Zim dictionary initializing failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
continue;
|
||||
}
|
||||
catch ( ... ) {
|
||||
qWarning( "Zim dictionary initializing failed\n" );
|
||||
qWarning( "Zim dictionary initializing failed" );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "audiolink.hh"
|
||||
#include "indexedzip.hh"
|
||||
#include "filetype.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "chunkedstorage.hh"
|
||||
#include "htmlescape.hh"
|
||||
|
||||
|
@ -400,7 +399,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
string indexFile = indicesDir + dictId;
|
||||
|
||||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) {
|
||||
gdDebug( "Zips: Building the index for dictionary: %s\n", fileName.c_str() );
|
||||
qDebug( "Zips: Building the index for dictionary: %s", fileName.c_str() );
|
||||
|
||||
File::Index idx( indexFile, QIODevice::WriteOnly );
|
||||
IdxHeader idxHeader;
|
||||
|
@ -474,7 +473,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dictionaries.push_back( std::make_shared< ZipSoundsDictionary >( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Zipped sounds pack reading failed: %s, error: %s\n", fileName.c_str(), e.what() );
|
||||
qWarning( "Zipped sounds pack reading failed: %s, error: %s", fileName.c_str(), e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <QDir>
|
||||
#include <QTimer>
|
||||
#include "externalviewer.hh"
|
||||
#include "gddebug.hh"
|
||||
|
||||
ExternalViewer::ExternalViewer(
|
||||
const char * data, int size, QString const & extension, QString const & viewerCmdLine_, QObject * parent ):
|
||||
|
@ -26,7 +25,7 @@ ExternalViewer::ExternalViewer(
|
|||
|
||||
tempFile.close();
|
||||
|
||||
GD_DPRINTF( "%s\n", tempFile.fileName().toLocal8Bit().data() );
|
||||
qDebug( "%s", tempFile.fileName().toLocal8Bit().data() );
|
||||
}
|
||||
|
||||
void ExternalViewer::start()
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "ftshelpers.hh"
|
||||
#include "wstring_qt.hh"
|
||||
#include "dictfile.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "folding.hh"
|
||||
#include "utils.hh"
|
||||
|
||||
|
@ -253,7 +252,7 @@ void FTSResultsRequest::run()
|
|||
qWarning() << e.get_description().c_str();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "FTS: Failed full-text search for \"%s\", reason: %s\n", dict.getName().c_str(), ex.what() );
|
||||
qWarning( "FTS: Failed full-text search for \"%s\", reason: %s", dict.getName().c_str(), ex.what() );
|
||||
// Results not loaded -- we don't set the hasAnyData flag then
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "ftshelpers.hh"
|
||||
#include "fulltextsearch.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "globalregex.hh"
|
||||
#include "help.hh"
|
||||
#include <QFutureSynchronizer>
|
||||
|
@ -46,7 +45,7 @@ void Indexing::run()
|
|||
timerThread->wait();
|
||||
}
|
||||
catch ( std::exception & ex ) {
|
||||
gdWarning( "Exception occurred while full-text search: %s", ex.what() );
|
||||
qWarning( "Exception occurred while full-text search: %s", ex.what() );
|
||||
}
|
||||
emit sendNowIndexingName( QString() );
|
||||
}
|
||||
|
@ -389,7 +388,7 @@ void FullTextSearchDialog::searchReqFinished()
|
|||
std::list< sptr< Dictionary::DataRequest > >::iterator it;
|
||||
for ( it = searchReqs.begin(); it != searchReqs.end(); ++it ) {
|
||||
if ( ( *it )->isFinished() ) {
|
||||
GD_DPRINTF( "one finished.\n" );
|
||||
qDebug( "one finished." );
|
||||
|
||||
QString errorString = ( *it )->getErrorString();
|
||||
|
||||
|
@ -405,7 +404,7 @@ void FullTextSearchDialog::searchReqFinished()
|
|||
addSortedHeadwords( allHeadwords, hws );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "getDataSlice error: %s\n", e.what() );
|
||||
qWarning( "getDataSlice error: %s", e.what() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -413,9 +412,9 @@ void FullTextSearchDialog::searchReqFinished()
|
|||
}
|
||||
}
|
||||
if ( it != searchReqs.end() ) {
|
||||
GD_DPRINTF( "erasing..\n" );
|
||||
qDebug( "erasing.." );
|
||||
searchReqs.erase( it );
|
||||
GD_DPRINTF( "erase done..\n" );
|
||||
qDebug( "erase done.." );
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "hotkeywrapper.hh"
|
||||
#include "gddebug.hh"
|
||||
#include <QTimer>
|
||||
#include <QSessionManager>
|
||||
#include <QWidget>
|
||||
|
@ -251,329 +250,4 @@ bool HotkeyWrapper::checkState( quint32 vk, quint32 mod )
|
|||
state2 = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <X11/keysym.h>
|
||||
|
||||
void HotkeyWrapper::init()
|
||||
{
|
||||
keyToUngrab = grabbedKeys.end();
|
||||
|
||||
#if QT_VERSION < 0x060000
|
||||
Display * displayID = QX11Info::display();
|
||||
#else
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
Display * displayID = x11AppInfo->display();
|
||||
#endif
|
||||
|
||||
// We use RECORD extension instead of XGrabKey. That's because XGrabKey
|
||||
// prevents other clients from getting their input if it's grabbed.
|
||||
|
||||
Display * display = displayID;
|
||||
|
||||
lShiftCode = XKeysymToKeycode( display, XK_Shift_L );
|
||||
rShiftCode = XKeysymToKeycode( display, XK_Shift_R );
|
||||
|
||||
lCtrlCode = XKeysymToKeycode( display, XK_Control_L );
|
||||
rCtrlCode = XKeysymToKeycode( display, XK_Control_R );
|
||||
|
||||
lAltCode = XKeysymToKeycode( display, XK_Alt_L );
|
||||
rAltCode = XKeysymToKeycode( display, XK_Alt_R );
|
||||
|
||||
lMetaCode = XKeysymToKeycode( display, XK_Super_L );
|
||||
rMetaCode = XKeysymToKeycode( display, XK_Super_R );
|
||||
|
||||
cCode = XKeysymToKeycode( display, XK_c );
|
||||
insertCode = XKeysymToKeycode( display, XK_Insert );
|
||||
kpInsertCode = XKeysymToKeycode( display, XK_KP_Insert );
|
||||
|
||||
currentModifiers = 0;
|
||||
|
||||
// This one will be used to read the recorded content
|
||||
dataDisplay = XOpenDisplay( 0 );
|
||||
|
||||
if ( !dataDisplay )
|
||||
throw exInit();
|
||||
|
||||
recordRange = XRecordAllocRange();
|
||||
|
||||
if ( !recordRange ) {
|
||||
XCloseDisplay( dataDisplay );
|
||||
throw exInit();
|
||||
}
|
||||
|
||||
recordRange->device_events.first = KeyPress;
|
||||
recordRange->device_events.last = KeyRelease;
|
||||
recordClientSpec = XRecordAllClients;
|
||||
|
||||
recordContext = XRecordCreateContext( display, 0, &recordClientSpec, 1, &recordRange, 1 );
|
||||
|
||||
if ( !recordContext ) {
|
||||
XFree( recordRange );
|
||||
XCloseDisplay( dataDisplay );
|
||||
throw exInit();
|
||||
}
|
||||
|
||||
// This is required to ensure context was indeed created
|
||||
XSync( display, False );
|
||||
|
||||
connect( this, &HotkeyWrapper::keyRecorded, this, &HotkeyWrapper::checkState, Qt::QueuedConnection );
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
void HotkeyWrapper::run() // Runs in a separate thread
|
||||
{
|
||||
if ( !XRecordEnableContext( dataDisplay, recordContext, recordEventCallback, (XPointer)this ) )
|
||||
GD_DPRINTF( "Failed to enable record context\n" );
|
||||
}
|
||||
|
||||
|
||||
void HotkeyWrapper::recordEventCallback( XPointer ptr, XRecordInterceptData * data )
|
||||
{
|
||||
( (HotkeyWrapper *)ptr )->handleRecordEvent( data );
|
||||
}
|
||||
|
||||
void HotkeyWrapper::handleRecordEvent( XRecordInterceptData * data )
|
||||
{
|
||||
if ( data->category == XRecordFromServer ) {
|
||||
xEvent * event = (xEvent *)data->data;
|
||||
|
||||
if ( event->u.u.type == KeyPress ) {
|
||||
KeyCode key = event->u.u.detail;
|
||||
|
||||
if ( key == lShiftCode || key == rShiftCode )
|
||||
currentModifiers |= ShiftMask;
|
||||
else if ( key == lCtrlCode || key == rCtrlCode )
|
||||
currentModifiers |= ControlMask;
|
||||
else if ( key == lAltCode || key == rAltCode )
|
||||
currentModifiers |= Mod1Mask;
|
||||
else if ( key == lMetaCode || key == rMetaCode )
|
||||
currentModifiers |= Mod4Mask;
|
||||
else {
|
||||
// Here we employ a kind of hack translating KP_Insert key
|
||||
// to just Insert. This allows reacting to both Insert keys.
|
||||
if ( key == kpInsertCode )
|
||||
key = insertCode;
|
||||
|
||||
emit keyRecorded( key, currentModifiers );
|
||||
}
|
||||
}
|
||||
else if ( event->u.u.type == KeyRelease ) {
|
||||
KeyCode key = event->u.u.detail;
|
||||
|
||||
if ( key == lShiftCode || key == rShiftCode )
|
||||
currentModifiers &= ~ShiftMask;
|
||||
else if ( key == lCtrlCode || key == rCtrlCode )
|
||||
currentModifiers &= ~ControlMask;
|
||||
else if ( key == lAltCode || key == rAltCode )
|
||||
currentModifiers &= ~Mod1Mask;
|
||||
else if ( key == lMetaCode || key == rMetaCode )
|
||||
currentModifiers &= ~Mod4Mask;
|
||||
}
|
||||
}
|
||||
|
||||
XRecordFreeData( data );
|
||||
}
|
||||
|
||||
bool HotkeyWrapper::setGlobalKey( QKeySequence const & seq, int handle )
|
||||
{
|
||||
Config::HotKey hk( seq );
|
||||
return setGlobalKey( hk.key1, hk.key2, hk.modifiers, handle );
|
||||
}
|
||||
|
||||
bool HotkeyWrapper::setGlobalKey( int key, int key2, Qt::KeyboardModifiers modifier, int handle )
|
||||
{
|
||||
if ( !key )
|
||||
return false; // We don't monitor empty combinations
|
||||
|
||||
int vk = nativeKey( key );
|
||||
int vk2 = key2 ? nativeKey( key2 ) : 0;
|
||||
|
||||
quint32 mod = 0;
|
||||
if ( modifier & Qt::ShiftModifier )
|
||||
mod |= ShiftMask;
|
||||
if ( modifier & Qt::ControlModifier )
|
||||
mod |= ControlMask;
|
||||
if ( modifier & Qt::AltModifier )
|
||||
mod |= Mod1Mask;
|
||||
if ( modifier & Qt::MetaModifier )
|
||||
mod |= Mod4Mask;
|
||||
|
||||
hotkeys.append( HotkeyStruct( vk, vk2, mod, handle, 0 ) );
|
||||
|
||||
if ( !isCopyToClipboardKey( vk, mod ) )
|
||||
grabKey( vk, mod ); // Make sure it doesn't get caught by other apps
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HotkeyWrapper::isCopyToClipboardKey( quint32 keyCode, quint32 modifiers ) const
|
||||
{
|
||||
return modifiers == ControlMask && ( keyCode == cCode || keyCode == insertCode || keyCode == kpInsertCode );
|
||||
}
|
||||
|
||||
bool HotkeyWrapper::isKeyGrabbed( quint32 keyCode, quint32 modifiers ) const
|
||||
{
|
||||
GrabbedKeys::const_iterator i = grabbedKeys.find( std::make_pair( keyCode, modifiers ) );
|
||||
|
||||
return i != grabbedKeys.end();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
using X11ErrorHandler = int ( * )( Display * display, XErrorEvent * event );
|
||||
|
||||
class X11GrabUngrabErrorHandler
|
||||
{
|
||||
public:
|
||||
static bool error;
|
||||
|
||||
static int grab_ungrab_error_handler( Display *, XErrorEvent * event )
|
||||
{
|
||||
qDebug() << "grab_ungrab_error_handler is invoked";
|
||||
switch ( event->error_code ) {
|
||||
case BadAccess:
|
||||
case BadValue:
|
||||
case BadWindow:
|
||||
if ( event->request_code == 33 /* X_GrabKey */ || event->request_code == 34 /* X_UngrabKey */ ) {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
X11GrabUngrabErrorHandler()
|
||||
{
|
||||
error = false;
|
||||
previousErrorHandler_ = XSetErrorHandler( grab_ungrab_error_handler );
|
||||
}
|
||||
|
||||
~X11GrabUngrabErrorHandler()
|
||||
{
|
||||
#if QT_VERSION < 0x060000
|
||||
Display * displayID = QX11Info::display();
|
||||
#else
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
Display * displayID = x11AppInfo->display();
|
||||
#endif
|
||||
XFlush( displayID );
|
||||
(void)XSetErrorHandler( previousErrorHandler_ );
|
||||
}
|
||||
|
||||
bool isError() const
|
||||
{
|
||||
#if QT_VERSION < 0x060000
|
||||
Display * displayID = QX11Info::display();
|
||||
#else
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
Display * displayID = x11AppInfo->display();
|
||||
#endif
|
||||
XFlush( displayID );
|
||||
return error;
|
||||
}
|
||||
|
||||
private:
|
||||
X11ErrorHandler previousErrorHandler_;
|
||||
};
|
||||
|
||||
bool X11GrabUngrabErrorHandler::error = false;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
HotkeyWrapper::GrabbedKeys::iterator HotkeyWrapper::grabKey( quint32 keyCode, quint32 modifiers )
|
||||
{
|
||||
std::pair< GrabbedKeys::iterator, bool > result = grabbedKeys.insert( std::make_pair( keyCode, modifiers ) );
|
||||
|
||||
|
||||
if ( result.second ) {
|
||||
#if QT_VERSION < 0x060000
|
||||
Display * displayID = QX11Info::display();
|
||||
#else
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
Display * displayID = x11AppInfo->display();
|
||||
#endif
|
||||
X11GrabUngrabErrorHandler errorHandler;
|
||||
XGrabKey( displayID, keyCode, modifiers, DefaultRootWindow( displayID ), True, GrabModeAsync, GrabModeAsync );
|
||||
|
||||
if ( errorHandler.isError() ) {
|
||||
gdWarning( "Possible hotkeys conflict. Check your hotkeys options." );
|
||||
ungrabKey( result.first );
|
||||
}
|
||||
}
|
||||
|
||||
return result.first;
|
||||
}
|
||||
|
||||
void HotkeyWrapper::ungrabKey( GrabbedKeys::iterator i )
|
||||
{
|
||||
#if QT_VERSION < 0x060000
|
||||
Display * displayID = QX11Info::display();
|
||||
#else
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
Display * displayID = x11AppInfo->display();
|
||||
#endif
|
||||
X11GrabUngrabErrorHandler errorHandler;
|
||||
XUngrabKey( displayID, i->first, i->second, XDefaultRootWindow( displayID ) );
|
||||
|
||||
grabbedKeys.erase( i );
|
||||
|
||||
if ( errorHandler.isError() ) {
|
||||
gdWarning( "Cannot ungrab the hotkey" );
|
||||
}
|
||||
}
|
||||
|
||||
quint32 HotkeyWrapper::nativeKey( int key )
|
||||
{
|
||||
QString keySymName;
|
||||
|
||||
switch ( key ) {
|
||||
case Qt::Key_Insert:
|
||||
keySymName = "Insert";
|
||||
break;
|
||||
default:
|
||||
keySymName = QKeySequence( key ).toString();
|
||||
break;
|
||||
}
|
||||
#if QT_VERSION < 0x060000
|
||||
Display * displayID = QX11Info::display();
|
||||
#else
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
Display * displayID = x11AppInfo->display();
|
||||
#endif
|
||||
Display * display = displayID;
|
||||
return XKeysymToKeycode( display, XStringToKeysym( keySymName.toLatin1().data() ) );
|
||||
}
|
||||
|
||||
void HotkeyWrapper::unregister()
|
||||
{
|
||||
#if QT_VERSION < 0x060000
|
||||
Display * displayID = QX11Info::display();
|
||||
#else
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
Display * displayID = x11AppInfo->display();
|
||||
#endif
|
||||
Display * display = displayID;
|
||||
|
||||
XRecordDisableContext( display, recordContext );
|
||||
XSync( display, False );
|
||||
|
||||
wait();
|
||||
|
||||
XRecordFreeContext( display, recordContext );
|
||||
XFree( recordRange );
|
||||
XCloseDisplay( dataDisplay );
|
||||
|
||||
while ( grabbedKeys.size() )
|
||||
ungrabKey( grabbedKeys.begin() );
|
||||
|
||||
( static_cast< QHotkeyApplication * >( qApp ) )->unregisterWrapper( this );
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,35 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
/// @file
|
||||
/// Handling global hotkeys and some tricks
|
||||
/// Part of this header are implmented in
|
||||
/// + `winhotkeywrapper.cc`
|
||||
/// + `machotkeywrapper.hh`
|
||||
///
|
||||
/// Handling global hotkeys and some trick
|
||||
/// Part of this header is implemented in
|
||||
/// + `winhotkeywrapper`
|
||||
/// + `machotkeywrapper`
|
||||
/// + `x11hotkeywrapper`
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QThread>
|
||||
|
||||
#include "config.hh"
|
||||
#include "ex.hh"
|
||||
#include "qtsingleapplication.h"
|
||||
#include "utils.hh"
|
||||
|
||||
#ifdef HAVE_X11
|
||||
|
||||
#include <fixx11h.h>
|
||||
#include <set>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/record.h>
|
||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
||||
#include <QX11Info>
|
||||
#endif
|
||||
#include <X11/Xlibint.h>
|
||||
|
||||
#undef Bool
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -130,7 +123,7 @@ private:
|
|||
/// Called by recordEventCallback()
|
||||
void handleRecordEvent( XRecordInterceptData * );
|
||||
|
||||
void run(); // QThread
|
||||
void run() override; // QThread
|
||||
|
||||
// We do one-time init of those, translating keysyms to keycodes
|
||||
KeyCode lShiftCode, rShiftCode, lCtrlCode, rCtrlCode, lAltCode, rAltCode, cCode, insertCode, kpInsertCode, lMetaCode,
|
||||
|
|
37
src/main.cc
37
src/main.cc
|
@ -1,16 +1,24 @@
|
|||
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
||||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <QIcon>
|
||||
#include "mainwindow.hh"
|
||||
#include "config.hh"
|
||||
#include <QWebEngineProfile>
|
||||
#include "hotkeywrapper.hh"
|
||||
#include "logfileptr.hh"
|
||||
#include "mainwindow.hh"
|
||||
#include "termination.hh"
|
||||
#include "version.hh"
|
||||
#ifdef HAVE_X11
|
||||
#include <fixx11h.h>
|
||||
#endif
|
||||
#include <QByteArray>
|
||||
#include <QCommandLineParser>
|
||||
#include <QFile>
|
||||
#include <QIcon>
|
||||
#include <QMessageBox>
|
||||
#include <QMutex>
|
||||
#include <QString>
|
||||
#include <QStringBuilder>
|
||||
#include <QtWebEngineCore/QWebEngineUrlScheme>
|
||||
#include <stdio.h>
|
||||
#include <QStyleFactory>
|
||||
|
||||
#include "hotkeywrapper.hh" // X11 headers & fixer causes this file must be included last
|
||||
|
||||
#if defined( Q_OS_UNIX )
|
||||
#include <clocale>
|
||||
|
@ -21,19 +29,6 @@
|
|||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "termination.hh"
|
||||
#include <QByteArray>
|
||||
#include <QCommandLineParser>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QString>
|
||||
#include <QStringBuilder>
|
||||
#include <QtWebEngineCore/QWebEngineUrlScheme>
|
||||
|
||||
#include "gddebug.hh"
|
||||
#include <QMutex>
|
||||
#include <QStyleFactory>
|
||||
|
||||
#if defined( USE_BREAKPAD )
|
||||
#if defined( Q_OS_MAC )
|
||||
#include "client/mac/handler/exception_handler.h"
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
||||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||
|
||||
#include "logfileptr.hh"
|
||||
#include "termination.hh"
|
||||
#include <QDebug>
|
||||
#include <exception>
|
||||
#include <QtCore>
|
||||
|
||||
|
||||
static void termHandler()
|
||||
{
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QFile>
|
||||
|
||||
extern QFile * logFilePtr;
|
||||
|
||||
// Installs the termination handler which attempts to pop Qt's dialog showing
|
||||
// the exception and backtrace, and then aborts.
|
||||
void installTerminationHandler();
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "articleview.hh"
|
||||
#include "dict/programs.hh"
|
||||
#include "folding.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "gestures.hh"
|
||||
#include "globalbroadcaster.hh"
|
||||
#include "speechclient.hh"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||
|
||||
#include "dictheadwords.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "headwordsmodel.hh"
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
@ -255,7 +254,7 @@ QRegularExpression DictHeadwords::getFilterRegex() const
|
|||
QRegularExpression regExp = QRegularExpression( pattern, options );
|
||||
|
||||
if ( !regExp.isValid() ) {
|
||||
gdWarning( "Invalid regexp pattern: %s\n", pattern.toUtf8().data() );
|
||||
qWarning( "Invalid regexp pattern: %s", pattern.toUtf8().data() );
|
||||
}
|
||||
return regExp;
|
||||
}
|
||||
|
@ -428,7 +427,7 @@ void DictHeadwords::saveHeadersToFile()
|
|||
progress.setValue( progress.maximum() );
|
||||
if ( progress.wasCanceled() ) {
|
||||
QMessageBox::warning( this, "GoldenDict", tr( "Export process is interrupted" ) );
|
||||
gdWarning( "Headers export error: %s", file.errorString().toUtf8().data() );
|
||||
qWarning( "Headers export error: %s", file.errorString().toUtf8().data() );
|
||||
}
|
||||
else {
|
||||
//completed.
|
||||
|
|
|
@ -210,7 +210,7 @@ void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended )
|
|||
|
||||
void DictionaryBar::mutedDictionariesChanged()
|
||||
{
|
||||
//GD_DPRINTF( "Muted dictionaries changed\n" );
|
||||
//qDebug( "Muted dictionaries changed" );
|
||||
|
||||
if ( !mutedDictionaries ) {
|
||||
return;
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
#include <functional>
|
||||
|
||||
#include "favoritespanewidget.hh"
|
||||
#include "gddebug.hh"
|
||||
#include "globalbroadcaster.hh"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
/************************************************** FavoritesPaneWidget *********************************************/
|
||||
|
||||
void FavoritesPaneWidget::setUp( Config::Class * cfg, QMenu * menu )
|
||||
|
@ -644,7 +645,7 @@ void FavoritesModel::readData()
|
|||
|
||||
QFile favoritesFile( m_favoritesFilename );
|
||||
if ( !favoritesFile.open( QFile::ReadOnly ) ) {
|
||||
gdDebug( "No favorites file found" );
|
||||
qDebug( "No favorites file found" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -654,7 +655,7 @@ void FavoritesModel::readData()
|
|||
|
||||
if ( !dom.setContent( &favoritesFile, false, &errorStr, &errorLine, &errorColumn ) ) {
|
||||
// Mailformed file
|
||||
gdWarning( "Favorites file parsing error: %s at %d,%d\n", errorStr.toUtf8().data(), errorLine, errorColumn );
|
||||
qWarning( "Favorites file parsing error: %s at %d,%d", errorStr.toUtf8().data(), errorLine, errorColumn );
|
||||
|
||||
QMessageBox mb( QMessageBox::Warning, "GoldenDict", tr( "Error in favorities file" ), QMessageBox::Ok );
|
||||
mb.exec();
|
||||
|
@ -686,7 +687,7 @@ void FavoritesModel::saveData()
|
|||
|
||||
QSaveFile tmpFile( m_favoritesFilename );
|
||||
if ( !tmpFile.open( QFile::WriteOnly ) ) {
|
||||
gdWarning( "Can't write favorites file, error: %s", tmpFile.errorString().toUtf8().data() );
|
||||
qWarning( "Can't write favorites file, error: %s", tmpFile.errorString().toUtf8().data() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -699,7 +700,7 @@ void FavoritesModel::saveData()
|
|||
QByteArray result( dom.toByteArray() );
|
||||
|
||||
if ( tmpFile.write( result ) != result.size() ) {
|
||||
gdWarning( "Can't write favorites file, error: %s", tmpFile.errorString().toUtf8().data() );
|
||||
qWarning( "Can't write favorites file, error: %s", tmpFile.errorString().toUtf8().data() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1145,7 +1146,7 @@ bool FavoritesModel::setDataFromXml( QString const & dataStr )
|
|||
|
||||
if ( !dom.setContent( dataStr, false, &errorStr, &errorLine, &errorColumn ) ) {
|
||||
// Mailformed data
|
||||
gdWarning( "XML parsing error: %s at %d,%d\n", errorStr.toUtf8().data(), errorLine, errorColumn );
|
||||
qWarning( "XML parsing error: %s at %d,%d", errorStr.toUtf8().data(), errorLine, errorColumn );
|
||||
dom.clear();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include "gddebug.hh"
|
||||
|
||||
#include "dictinfo.hh"
|
||||
#include "historypanewidget.hh"
|
||||
|
@ -1294,7 +1293,7 @@ void MainWindow::commitData()
|
|||
Config::save( cfg );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Configuration saving failed, error: %s\n", e.what() );
|
||||
qWarning( "Configuration saving failed, error: %s", e.what() );
|
||||
}
|
||||
|
||||
// Save history
|
||||
|
@ -1304,7 +1303,7 @@ void MainWindow::commitData()
|
|||
ui.favoritesPaneWidget->saveData();
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Commit data failed, error: %s\n", e.what() );
|
||||
qWarning( "Commit data failed, error: %s", e.what() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1577,7 +1576,7 @@ void MainWindow::setupNetworkCache( int maxSize )
|
|||
QString cacheDirectory = Config::getCacheDir();
|
||||
if ( !QDir().mkpath( cacheDirectory ) ) {
|
||||
cacheDirectory = QStandardPaths::writableLocation( QStandardPaths::CacheLocation );
|
||||
gdWarning( "Cannot create a cache directory %s. use default cache path.", cacheDirectory.toUtf8().constData() );
|
||||
qWarning( "Cannot create a cache directory %s. use default cache path.", cacheDirectory.toUtf8().constData() );
|
||||
}
|
||||
|
||||
QNetworkDiskCache * const diskCache = new QNetworkDiskCache( this );
|
||||
|
@ -4493,7 +4492,7 @@ void MainWindow::setGroupByName( QString const & name, bool main_window )
|
|||
}
|
||||
}
|
||||
if ( i >= groupList->count() ) {
|
||||
gdWarning( "Group \"%s\" for main window is not found\n", name.toUtf8().data() );
|
||||
qWarning( "Group \"%s\" for main window is not found", name.toUtf8().data() );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <QBitmap>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include "gddebug.hh"
|
||||
#include "gestures.hh"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
|
@ -51,7 +50,7 @@ static bool ownsClipboardMode( QClipboard::Mode mode )
|
|||
return clipboard.ownsFindBuffer();
|
||||
}
|
||||
|
||||
gdWarning( "Unknown clipboard mode: %d\n", static_cast< int >( mode ) );
|
||||
qWarning( "Unknown clipboard mode: %d", static_cast< int >( mode ) );
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -749,14 +748,14 @@ bool ScanPopup::eventFilter( QObject * watched, QEvent * event )
|
|||
void ScanPopup::reactOnMouseMove( QPointF const & p )
|
||||
{
|
||||
if ( geometry().contains( p.toPoint() ) ) {
|
||||
// GD_DPRINTF( "got inside\n" );
|
||||
// qDebug( "got inside" );
|
||||
|
||||
hideTimer.stop();
|
||||
mouseEnteredOnce = true;
|
||||
uninterceptMouse();
|
||||
}
|
||||
else {
|
||||
// GD_DPRINTF( "outside\n" );
|
||||
// qDebug( "outside" );
|
||||
// We're in grab mode and outside the window - calculate the
|
||||
// distance from it. We might want to hide it.
|
||||
|
||||
|
@ -1165,7 +1164,7 @@ void ScanPopup::setGroupByName( QString const & name ) const
|
|||
}
|
||||
}
|
||||
if ( i >= ui.groupList->count() ) {
|
||||
gdWarning( "Group \"%s\" for popup window is not found\n", name.toUtf8().data() );
|
||||
qWarning( "Group \"%s\" for popup window is not found", name.toUtf8().data() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
309
src/unix/x11hotkeywrapper.cc
Normal file
309
src/unix/x11hotkeywrapper.cc
Normal file
|
@ -0,0 +1,309 @@
|
|||
#ifdef HAVE_X11
|
||||
#include "hotkeywrapper.hh"
|
||||
#include <X11/keysym.h>
|
||||
|
||||
//
|
||||
/// Previously impletended with XGrabKey
|
||||
/// Then reimplemented with X Record Extension Library
|
||||
///
|
||||
|
||||
void HotkeyWrapper::init()
|
||||
{
|
||||
keyToUngrab = grabbedKeys.end();
|
||||
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
Display * displayID = x11AppInfo->display();
|
||||
|
||||
// We use RECORD extension instead of XGrabKey. That's because XGrabKey
|
||||
// prevents other clients from getting their input if it's grabbed.
|
||||
|
||||
Display * display = displayID;
|
||||
|
||||
lShiftCode = XKeysymToKeycode( display, XK_Shift_L );
|
||||
rShiftCode = XKeysymToKeycode( display, XK_Shift_R );
|
||||
|
||||
lCtrlCode = XKeysymToKeycode( display, XK_Control_L );
|
||||
rCtrlCode = XKeysymToKeycode( display, XK_Control_R );
|
||||
|
||||
lAltCode = XKeysymToKeycode( display, XK_Alt_L );
|
||||
rAltCode = XKeysymToKeycode( display, XK_Alt_R );
|
||||
|
||||
lMetaCode = XKeysymToKeycode( display, XK_Super_L );
|
||||
rMetaCode = XKeysymToKeycode( display, XK_Super_R );
|
||||
|
||||
cCode = XKeysymToKeycode( display, XK_c );
|
||||
insertCode = XKeysymToKeycode( display, XK_Insert );
|
||||
kpInsertCode = XKeysymToKeycode( display, XK_KP_Insert );
|
||||
|
||||
currentModifiers = 0;
|
||||
|
||||
// This one will be used to read the recorded content
|
||||
dataDisplay = XOpenDisplay( 0 );
|
||||
|
||||
if ( !dataDisplay )
|
||||
throw exInit();
|
||||
|
||||
recordRange = XRecordAllocRange();
|
||||
|
||||
if ( !recordRange ) {
|
||||
XCloseDisplay( dataDisplay );
|
||||
throw exInit();
|
||||
}
|
||||
|
||||
recordRange->device_events.first = KeyPress;
|
||||
recordRange->device_events.last = KeyRelease;
|
||||
recordClientSpec = XRecordAllClients;
|
||||
|
||||
recordContext = XRecordCreateContext( display, 0, &recordClientSpec, 1, &recordRange, 1 );
|
||||
|
||||
if ( !recordContext ) {
|
||||
XFree( recordRange );
|
||||
XCloseDisplay( dataDisplay );
|
||||
throw exInit();
|
||||
}
|
||||
|
||||
// This is required to ensure context was indeed created
|
||||
XSync( display, False );
|
||||
|
||||
connect( this, &HotkeyWrapper::keyRecorded, this, &HotkeyWrapper::checkState, Qt::QueuedConnection );
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
void HotkeyWrapper::run() // Runs in a separate thread
|
||||
{
|
||||
if ( !XRecordEnableContext( dataDisplay, recordContext, recordEventCallback, (XPointer)this ) )
|
||||
qDebug( "Failed to enable record context" );
|
||||
}
|
||||
|
||||
|
||||
void HotkeyWrapper::recordEventCallback( XPointer ptr, XRecordInterceptData * data )
|
||||
{
|
||||
( (HotkeyWrapper *)ptr )->handleRecordEvent( data );
|
||||
}
|
||||
|
||||
void HotkeyWrapper::handleRecordEvent( XRecordInterceptData * data )
|
||||
{
|
||||
if ( data->category == XRecordFromServer ) {
|
||||
xEvent * event = (xEvent *)data->data;
|
||||
|
||||
if ( event->u.u.type == KeyPress ) {
|
||||
KeyCode key = event->u.u.detail;
|
||||
|
||||
if ( key == lShiftCode || key == rShiftCode )
|
||||
currentModifiers |= ShiftMask;
|
||||
else if ( key == lCtrlCode || key == rCtrlCode )
|
||||
currentModifiers |= ControlMask;
|
||||
else if ( key == lAltCode || key == rAltCode )
|
||||
currentModifiers |= Mod1Mask;
|
||||
else if ( key == lMetaCode || key == rMetaCode )
|
||||
currentModifiers |= Mod4Mask;
|
||||
else {
|
||||
// Here we employ a kind of hack translating KP_Insert key
|
||||
// to just Insert. This allows reacting to both Insert keys.
|
||||
if ( key == kpInsertCode )
|
||||
key = insertCode;
|
||||
|
||||
emit keyRecorded( key, currentModifiers );
|
||||
}
|
||||
}
|
||||
else if ( event->u.u.type == KeyRelease ) {
|
||||
KeyCode key = event->u.u.detail;
|
||||
|
||||
if ( key == lShiftCode || key == rShiftCode )
|
||||
currentModifiers &= ~ShiftMask;
|
||||
else if ( key == lCtrlCode || key == rCtrlCode )
|
||||
currentModifiers &= ~ControlMask;
|
||||
else if ( key == lAltCode || key == rAltCode )
|
||||
currentModifiers &= ~Mod1Mask;
|
||||
else if ( key == lMetaCode || key == rMetaCode )
|
||||
currentModifiers &= ~Mod4Mask;
|
||||
}
|
||||
}
|
||||
|
||||
XRecordFreeData( data );
|
||||
}
|
||||
|
||||
bool HotkeyWrapper::setGlobalKey( QKeySequence const & seq, int handle )
|
||||
{
|
||||
Config::HotKey hk( seq );
|
||||
return setGlobalKey( hk.key1, hk.key2, hk.modifiers, handle );
|
||||
}
|
||||
|
||||
bool HotkeyWrapper::setGlobalKey( int key, int key2, Qt::KeyboardModifiers modifier, int handle )
|
||||
{
|
||||
if ( !key )
|
||||
return false; // We don't monitor empty combinations
|
||||
|
||||
int vk = nativeKey( key );
|
||||
int vk2 = key2 ? nativeKey( key2 ) : 0;
|
||||
|
||||
quint32 mod = 0;
|
||||
if ( modifier & Qt::ShiftModifier )
|
||||
mod |= ShiftMask;
|
||||
if ( modifier & Qt::ControlModifier )
|
||||
mod |= ControlMask;
|
||||
if ( modifier & Qt::AltModifier )
|
||||
mod |= Mod1Mask;
|
||||
if ( modifier & Qt::MetaModifier )
|
||||
mod |= Mod4Mask;
|
||||
|
||||
hotkeys.append( HotkeyStruct( vk, vk2, mod, handle, 0 ) );
|
||||
|
||||
if ( !isCopyToClipboardKey( vk, mod ) )
|
||||
grabKey( vk, mod ); // Make sure it doesn't get caught by other apps
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HotkeyWrapper::isCopyToClipboardKey( quint32 keyCode, quint32 modifiers ) const
|
||||
{
|
||||
return modifiers == ControlMask && ( keyCode == cCode || keyCode == insertCode || keyCode == kpInsertCode );
|
||||
}
|
||||
|
||||
bool HotkeyWrapper::isKeyGrabbed( quint32 keyCode, quint32 modifiers ) const
|
||||
{
|
||||
GrabbedKeys::const_iterator i = grabbedKeys.find( std::make_pair( keyCode, modifiers ) );
|
||||
|
||||
return i != grabbedKeys.end();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
using X11ErrorHandler = int ( * )( Display * display, XErrorEvent * event );
|
||||
|
||||
class X11GrabUngrabErrorHandler
|
||||
{
|
||||
public:
|
||||
static bool error;
|
||||
|
||||
static int grab_ungrab_error_handler( Display *, XErrorEvent * event )
|
||||
{
|
||||
qDebug() << "grab_ungrab_error_handler is invoked";
|
||||
switch ( event->error_code ) {
|
||||
case BadAccess:
|
||||
case BadValue:
|
||||
case BadWindow:
|
||||
if ( event->request_code == 33 /* X_GrabKey */ || event->request_code == 34 /* X_UngrabKey */ ) {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
X11GrabUngrabErrorHandler()
|
||||
{
|
||||
error = false;
|
||||
previousErrorHandler_ = XSetErrorHandler( grab_ungrab_error_handler );
|
||||
}
|
||||
|
||||
~X11GrabUngrabErrorHandler()
|
||||
{
|
||||
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
|
||||
Display * displayID = x11AppInfo->display();
|
||||
|
||||
XFlush( displayID );
|
||||
(void)XSetErrorHandler( previousErrorHandler_ );
|
||||
}
|
||||
|
||||
bool isError() const
|
||||
{
|
||||
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
|
||||
Display * displayID = x11AppInfo->display();
|
||||
|
||||
XFlush( displayID );
|
||||
return error;
|
||||
}
|
||||
|
||||
private:
|
||||
X11ErrorHandler previousErrorHandler_;
|
||||
};
|
||||
|
||||
bool X11GrabUngrabErrorHandler::error = false;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
HotkeyWrapper::GrabbedKeys::iterator HotkeyWrapper::grabKey( quint32 keyCode, quint32 modifiers )
|
||||
{
|
||||
std::pair< GrabbedKeys::iterator, bool > result = grabbedKeys.insert( std::make_pair( keyCode, modifiers ) );
|
||||
|
||||
|
||||
if ( result.second ) {
|
||||
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
|
||||
Display * displayID = x11AppInfo->display();
|
||||
|
||||
X11GrabUngrabErrorHandler errorHandler;
|
||||
XGrabKey( displayID, keyCode, modifiers, DefaultRootWindow( displayID ), True, GrabModeAsync, GrabModeAsync );
|
||||
|
||||
if ( errorHandler.isError() ) {
|
||||
qWarning( "Possible hotkeys conflict. Check your hotkeys options." );
|
||||
ungrabKey( result.first );
|
||||
}
|
||||
}
|
||||
|
||||
return result.first;
|
||||
}
|
||||
|
||||
void HotkeyWrapper::ungrabKey( GrabbedKeys::iterator i )
|
||||
{
|
||||
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
|
||||
Display * displayID = x11AppInfo->display();
|
||||
X11GrabUngrabErrorHandler errorHandler;
|
||||
XUngrabKey( displayID, i->first, i->second, XDefaultRootWindow( displayID ) );
|
||||
|
||||
grabbedKeys.erase( i );
|
||||
|
||||
if ( errorHandler.isError() ) {
|
||||
qWarning( "Cannot ungrab the hotkey" );
|
||||
}
|
||||
}
|
||||
|
||||
quint32 HotkeyWrapper::nativeKey( int key )
|
||||
{
|
||||
QString keySymName;
|
||||
|
||||
switch ( key ) {
|
||||
case Qt::Key_Insert:
|
||||
keySymName = "Insert";
|
||||
break;
|
||||
default:
|
||||
keySymName = QKeySequence( key ).toString();
|
||||
break;
|
||||
}
|
||||
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
|
||||
Display * display = x11AppInfo->display();
|
||||
return XKeysymToKeycode( display, XStringToKeysym( keySymName.toLatin1().data() ) );
|
||||
}
|
||||
|
||||
void HotkeyWrapper::unregister()
|
||||
{
|
||||
QNativeInterface::QX11Application * x11AppInfo = qApp->nativeInterface< QNativeInterface::QX11Application >();
|
||||
Display * display = x11AppInfo->display();
|
||||
|
||||
XRecordDisableContext( display, recordContext );
|
||||
XSync( display, False );
|
||||
|
||||
wait();
|
||||
|
||||
XRecordFreeContext( display, recordContext );
|
||||
XFree( recordRange );
|
||||
XCloseDisplay( dataDisplay );
|
||||
|
||||
while ( grabbedKeys.size() )
|
||||
ungrabKey( grabbedKeys.begin() );
|
||||
|
||||
( static_cast< QHotkeyApplication * >( qApp ) )->unregisterWrapper( this );
|
||||
}
|
||||
|
||||
#endif
|
|
@ -5,7 +5,7 @@
|
|||
#include "folding.hh"
|
||||
#include "wstring_qt.hh"
|
||||
#include <map>
|
||||
#include "gddebug.hh"
|
||||
|
||||
|
||||
using std::vector;
|
||||
using std::list;
|
||||
|
@ -157,10 +157,10 @@ void WordFinder::startSearch()
|
|||
queuedRequests.push_back( sr );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "Word \"%s\" search error (%s) in \"%s\"\n",
|
||||
inputWord.toUtf8().data(),
|
||||
e.what(),
|
||||
inputDict->getName().c_str() );
|
||||
qWarning( "Word \"%s\" search error (%s) in \"%s\"",
|
||||
inputWord.toUtf8().data(),
|
||||
e.what(),
|
||||
inputDict->getName().c_str() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue