Skip to content

Commit

Permalink
opt: reply remove unnecessary signal (#1866)
Browse files Browse the repository at this point in the history
* opt: remove unnecessary signal



---------

Co-authored-by: shenleban tongying <shenlebantongying@gmail.com>
  • Loading branch information
xiaoyifang and shenlebantongying authored Oct 26, 2024
1 parent 7229fae commit 15207cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 51 deletions.
47 changes: 5 additions & 42 deletions src/article_netmgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,23 @@ AllowFrameReply::AllowFrameReply( QNetworkReply * _reply ):
setRequest( baseReply->request() );
setUrl( baseReply->url() );

// Signals to own slots

connect( baseReply, &QNetworkReply::metaDataChanged, this, &AllowFrameReply::applyMetaData );
QList< QByteArray > rawHeaders = baseReply->rawHeaderList();
for ( const auto & header : rawHeaders ) {
if ( header.toLower() != "x-frame-options" )
setRawHeader( header, baseReply->rawHeader( header ) );
}

connect( baseReply, &QNetworkReply::errorOccurred, this, &AllowFrameReply::applyError );

connect( baseReply, &QIODevice::readyRead, this, &QIODevice::readyRead );

// Redirect QNetworkReply signals

connect( baseReply, &QNetworkReply::downloadProgress, this, &QNetworkReply::downloadProgress );

connect( baseReply, &QNetworkReply::encrypted, this, &QNetworkReply::encrypted );

connect( baseReply, &QNetworkReply::finished, this, &QNetworkReply::finished );

connect( baseReply,
&QNetworkReply::preSharedKeyAuthenticationRequired,
this,
&QNetworkReply::preSharedKeyAuthenticationRequired );

connect( baseReply, &QNetworkReply::redirected, this, &QNetworkReply::redirected );

connect( baseReply, &QNetworkReply::sslErrors, this, &QNetworkReply::sslErrors );

connect( baseReply, &QNetworkReply::uploadProgress, this, &QNetworkReply::uploadProgress );

// Redirect QIODevice signals

connect( baseReply, &QIODevice::aboutToClose, this, &QIODevice::aboutToClose );

connect( baseReply, &QIODevice::bytesWritten, this, &QIODevice::bytesWritten );

connect( baseReply, &QIODevice::readChannelFinished, this, &QIODevice::readChannelFinished );

setOpenMode( QIODevice::ReadOnly );
}

void AllowFrameReply::applyMetaData()
{
// The webengine does not support to customize the headers right now ,maybe until Qt6.7 there should be some api supports
}

void AllowFrameReply::setReadBufferSize( qint64 size )
{
QNetworkReply::setReadBufferSize( size );
baseReply->setReadBufferSize( size );
}

qint64 AllowFrameReply::bytesAvailable() const
{
return baseReply->bytesAvailable();
Expand All @@ -89,11 +57,6 @@ qint64 AllowFrameReply::readData( char * data, qint64 maxSize )
baseReply->read( data, size );
return size;
}
void AllowFrameReply::finishedSlot()
{
setFinished( true );
emit finished();
}

QNetworkReply * ArticleNetworkAccessManager::getArticleReply( QNetworkRequest const & req )
{
Expand Down
11 changes: 2 additions & 9 deletions src/article_netmgr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,14 @@ public:
delete baseReply;
}

// QNetworkReply virtual functions
void setReadBufferSize( qint64 size );
void close()
{
baseReply->close();
}

// QIODevice virtual functions
qint64 bytesAvailable() const;
bool atEnd() const
bool atEnd() const override
{
return baseReply->atEnd();
}
Expand Down Expand Up @@ -81,11 +79,7 @@ public:
}

public slots:

// Own AllowFrameReply slots
void applyMetaData();
void applyError( QNetworkReply::NetworkError code );
// void readDataFromBase();

// Redirect QNetworkReply slots
virtual void abort()
Expand All @@ -96,7 +90,6 @@ public slots:
{
baseReply->ignoreSslErrors();
}
void finishedSlot();

protected:
// QNetworkReply virtual functions
Expand Down Expand Up @@ -186,7 +179,7 @@ public:
protected:

virtual qint64 bytesAvailable() const;
bool atEnd() const;
bool atEnd() const override;
virtual void abort() {}
virtual qint64 readData( char * data, qint64 maxSize );

Expand Down

0 comments on commit 15207cf

Please sign in to comment.