mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 10:52:49 +00:00
kio: SlaveInterface::dispatch() optimization
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
5d920b66f2
commit
d3426e8206
2 changed files with 161 additions and 149 deletions
|
@ -141,34 +141,32 @@ template<int T> struct PIDType { typedef pid_t PID_t; } ;
|
|||
template<> struct PIDType<2> { typedef qint16 PID_t; } ;
|
||||
template<> struct PIDType<4> { typedef qint32 PID_t; } ;
|
||||
|
||||
bool SlaveInterface::dispatch(int _cmd, const QByteArray &rawdata)
|
||||
bool SlaveInterface::dispatch(int cmd, const QByteArray &rawdata)
|
||||
{
|
||||
Q_D(SlaveInterface);
|
||||
//kDebug(7007) << "dispatch " << _cmd;
|
||||
//kDebug(7007) << "dispatch " << cmd;
|
||||
|
||||
QDataStream stream(rawdata);
|
||||
|
||||
QString str1;
|
||||
qint32 i;
|
||||
qint8 b;
|
||||
quint32 ul;
|
||||
|
||||
switch(_cmd) {
|
||||
switch(cmd) {
|
||||
case MSG_DATA:
|
||||
emit data(rawdata);
|
||||
break;
|
||||
case MSG_DATA_REQ:
|
||||
case MSG_DATA_REQ: {
|
||||
emit dataReq();
|
||||
break;
|
||||
case MSG_OPENED:
|
||||
}
|
||||
case MSG_OPENED: {
|
||||
emit open();
|
||||
break;
|
||||
case MSG_FINISHED:
|
||||
}
|
||||
case MSG_FINISHED: {
|
||||
//kDebug(7007) << "Finished [this = " << this << "]";
|
||||
d->offset = 0;
|
||||
d->speed_timer.stop();
|
||||
emit finished();
|
||||
break;
|
||||
}
|
||||
case MSG_STAT_ENTRY: {
|
||||
UDSEntry entry;
|
||||
stream >> entry;
|
||||
|
@ -193,27 +191,34 @@ bool SlaveInterface::dispatch(int _cmd, const QByteArray &rawdata)
|
|||
emit canResume(d->offset);
|
||||
break;
|
||||
}
|
||||
case MSG_CANRESUME: // From the get job
|
||||
case MSG_CANRESUME: { // From the get job
|
||||
d->filesize = d->offset;
|
||||
emit canResume(0); // the arg doesn't matter
|
||||
break;
|
||||
case MSG_ERROR:
|
||||
stream >> i >> str1;
|
||||
kDebug(7007) << "error " << i << " " << str1;
|
||||
emit error(i, str1);
|
||||
}
|
||||
case MSG_ERROR: {
|
||||
qint32 i;
|
||||
QString str;
|
||||
stream >> i >> str;
|
||||
kDebug(7007) << "error " << i << " " << str;
|
||||
emit error(i, str);
|
||||
break;
|
||||
}
|
||||
case MSG_SLAVE_STATUS: {
|
||||
PIDType<sizeof(pid_t)>::PID_t stream_pid;
|
||||
pid_t pid;
|
||||
QByteArray protocol;
|
||||
stream >> stream_pid >> protocol >> str1 >> b;
|
||||
QString str;
|
||||
qint8 b;
|
||||
stream >> stream_pid >> protocol >> str >> b;
|
||||
pid = stream_pid;
|
||||
emit slaveStatus(pid, protocol, str1, (b != 0));
|
||||
emit slaveStatus(pid, protocol, str, (b != 0));
|
||||
break;
|
||||
}
|
||||
case MSG_CONNECTED:
|
||||
case MSG_CONNECTED: {
|
||||
emit connected();
|
||||
break;
|
||||
}
|
||||
case MSG_WRITTEN: {
|
||||
KIO::filesize_t size = readFilesize_t(stream);
|
||||
emit written(size);
|
||||
|
@ -243,28 +248,34 @@ bool SlaveInterface::dispatch(int _cmd, const QByteArray &rawdata)
|
|||
emit position(pos);
|
||||
break;
|
||||
}
|
||||
case INF_SPEED:
|
||||
case INF_SPEED: {
|
||||
quint32 ul;
|
||||
stream >> ul;
|
||||
d->slave_calcs_speed = true;
|
||||
d->speed_timer.stop();
|
||||
emit speed(ul);
|
||||
break;
|
||||
}
|
||||
case INF_REDIRECTION: {
|
||||
KUrl url;
|
||||
stream >> url;
|
||||
emit redirection(url);
|
||||
break;
|
||||
}
|
||||
case INF_MIME_TYPE:
|
||||
stream >> str1;
|
||||
emit mimeType(str1);
|
||||
case INF_MIME_TYPE: {
|
||||
QString str;
|
||||
stream >> str;
|
||||
emit mimeType(str);
|
||||
if (!d->connection->suspended())
|
||||
d->connection->sendnow(CMD_NONE, QByteArray());
|
||||
break;
|
||||
case INF_WARNING:
|
||||
stream >> str1;
|
||||
emit warning(str1);
|
||||
}
|
||||
case INF_WARNING: {
|
||||
QString str;
|
||||
stream >> str;
|
||||
emit warning(str);
|
||||
break;
|
||||
}
|
||||
case INF_MESSAGEBOX: {
|
||||
kDebug(7007) << "needs a msg box";
|
||||
QString text, caption, buttonYes, buttonNo, dontAskAgainName;
|
||||
|
@ -294,10 +305,11 @@ bool SlaveInterface::dispatch(int _cmd, const QByteArray &rawdata)
|
|||
emit needSubUrlData();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
kWarning(7007) << "Slave sends unknown command (" << _cmd << "), dropping slave";
|
||||
default: {
|
||||
kWarning(7007) << "Slave sends unknown command (" << cmd << "), dropping slave";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ protected:
|
|||
////////////////
|
||||
|
||||
virtual bool dispatch();
|
||||
virtual bool dispatch( int _cmd, const QByteArray &data );
|
||||
virtual bool dispatch( int cmd, const QByteArray &data );
|
||||
|
||||
void messageBox( int type, const QString &text, const QString &caption,
|
||||
const QString &buttonYes, const QString &buttonNo );
|
||||
|
|
Loading…
Add table
Reference in a new issue