mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kio: remove redundant KIO::Connection::inited() method
has the same meaning as isConnected() Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
fb1fc34008
commit
d006f066ee
3 changed files with 28 additions and 32 deletions
|
@ -129,24 +129,31 @@ bool SocketConnectionBackend::waitForIncomingTask(int ms)
|
|||
}
|
||||
|
||||
signalEmitted = false;
|
||||
if (socket->bytesAvailable())
|
||||
if (socket->bytesAvailable()) {
|
||||
socketReadyRead();
|
||||
if (signalEmitted)
|
||||
return true; // there was enough data in the socket
|
||||
}
|
||||
if (signalEmitted) {
|
||||
// there was enough data in the socket
|
||||
return true;
|
||||
}
|
||||
|
||||
// not enough data in the socket, so wait for more
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
while (socket->state() == QLocalSocket::ConnectedState && !signalEmitted &&
|
||||
(ms == -1 || timer.elapsed() < ms))
|
||||
if (!socket->waitForReadyRead(ms == -1 ? -1 : ms - timer.elapsed()))
|
||||
(ms == -1 || timer.elapsed() < ms)) {
|
||||
if (!socket->waitForReadyRead(ms == -1 ? -1 : ms - timer.elapsed())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (signalEmitted)
|
||||
if (signalEmitted) {
|
||||
return true;
|
||||
if (socket->state() != QLocalSocket::ConnectedState)
|
||||
}
|
||||
if (socket->state() != QLocalSocket::ConnectedState) {
|
||||
state = Idle;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -343,11 +350,6 @@ bool Connection::isConnected() const
|
|||
return m_backend && m_backend->state == SocketConnectionBackend::Connected;
|
||||
}
|
||||
|
||||
bool Connection::inited() const
|
||||
{
|
||||
return m_backend;
|
||||
}
|
||||
|
||||
bool Connection::suspended() const
|
||||
{
|
||||
return m_suspended;
|
||||
|
@ -384,7 +386,7 @@ QString Connection::errorString() const
|
|||
|
||||
bool Connection::send(int cmd, const QByteArray& data)
|
||||
{
|
||||
if (!inited() || !m_outgoingTasks.isEmpty()) {
|
||||
if (!isConnected() || !m_outgoingTasks.isEmpty()) {
|
||||
Task task;
|
||||
task.cmd = cmd;
|
||||
task.data = data;
|
||||
|
@ -394,17 +396,19 @@ bool Connection::send(int cmd, const QByteArray& data)
|
|||
return sendnow(cmd, data);
|
||||
}
|
||||
|
||||
bool Connection::sendnow(int _cmd, const QByteArray &data)
|
||||
bool Connection::sendnow(int cmd, const QByteArray &data)
|
||||
{
|
||||
if (data.size() > 0xffffff)
|
||||
if (data.size() > 0xffffff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isConnected())
|
||||
if (!isConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//kDebug() << this << "Sending command " << _cmd << " of size " << data.size();
|
||||
// kDebug() << this << "Sending command " << cmd << " of size " << data.size();
|
||||
Task task;
|
||||
task.cmd = _cmd;
|
||||
task.cmd = cmd;
|
||||
task.data = data;
|
||||
return m_backend->sendCommand(task);
|
||||
}
|
||||
|
@ -416,11 +420,12 @@ bool Connection::hasTaskAvailable() const
|
|||
|
||||
bool Connection::waitForIncomingTask(int ms)
|
||||
{
|
||||
if (!isConnected())
|
||||
if (!isConnected()) {
|
||||
return false;
|
||||
|
||||
if (m_backend)
|
||||
}
|
||||
if (m_backend) {
|
||||
return m_backend->waitForIncomingTask(ms);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,13 +101,6 @@ namespace KIO {
|
|||
|
||||
bool isConnected() const;
|
||||
|
||||
/**
|
||||
* Checks whether the connection has been initialized.
|
||||
* @return true if the initialized
|
||||
* @see init()
|
||||
*/
|
||||
bool inited() const;
|
||||
|
||||
/**
|
||||
* Sends/queues the given command to be sent.
|
||||
* @param cmd the command to set
|
||||
|
@ -137,7 +130,7 @@ namespace KIO {
|
|||
* @param ms the time to wait in milliseconds
|
||||
* @returns true if one command can be read, false if we timed out
|
||||
*/
|
||||
bool waitForIncomingTask(int ms = 30000);
|
||||
bool waitForIncomingTask(int ms);
|
||||
|
||||
/**
|
||||
* Receive data.
|
||||
|
|
|
@ -272,7 +272,7 @@ SlaveBase::SlaveBase(const QByteArray &protocol,
|
|||
|
||||
const QString address = QFile::decodeName(app_socket);
|
||||
d->appConnection.connectToRemote(address);
|
||||
if (!d->appConnection.inited()) {
|
||||
if (!d->appConnection.isConnected()) {
|
||||
kDebug(7019) << "failed to connect to" << address << '\n'
|
||||
<< "Reason:" << d->appConnection.errorString();
|
||||
exit();
|
||||
|
@ -297,8 +297,6 @@ void SlaveBase::dispatchLoop()
|
|||
special(data);
|
||||
}
|
||||
|
||||
Q_ASSERT(d->appConnection.inited());
|
||||
|
||||
int ms = -1;
|
||||
if (d->timeout) {
|
||||
ms = 1000 * qMax<time_t>(d->timeout - time(0), 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue