New KIO::Connection

Thiago Macieira thiago at kde.org
Wed Jul 11 14:48:16 BST 2007


Ralf Habacker wrote:
>To get this stuff initial running on win32 I added a an experimental tcp
>backend (see appended patch) and got kio_file with kioslavetest and kate
>running. It uses an url form of  tcp://<host>:<port> to make the
>Connection class able to select the correct backend.

Thank you Ralf, I'll add it to my local tree and enable it to see how it 
works.

>One problem i had with the code below (commented part), which raises
>the  Q_ASSERT(socket->bytesAvailable() == 1) all the time. Commenting
>out let kio_file works

That's probably some code that has to go away. The thing is, unlike 
previous socket implementations, QAbstractSocket only emits the 
readyRead() signal once for the data it already has. It needs to receive 
more data before it emits again.

But if you set the read buffer size and that buffer gets full, the socket 
notifier gets turned off. The only way to turn it back on is to read data 
from the QIODevice buffer. That's what that section of the code does.

The assertion is just to verify that it has 1 byte, which is what we set 
the read buffer size to. All we need to do is read (and unread) 1 single 
byte from the QAbstractSocket buffer, but the problem is: we have no idea 
how many bytes are in the QIODevice buffer... so we have to read all and 
then unread all.

Sounds like something that could be improved, though.

>Another issue I had with connectToRemote(). In the method the connection
>state is set unconditional, although there may be errors returning from
>connectToHost. I had added a workaround, there may be better solutions
>for this.

You're not supposed to use waitForConnected() with KSocketFactory-created 
sockets. It works now, but I make no promises it will continue working in 
the future. In special, if it requires downloading a JS script in order 
to find the proxy, it may have to leave the returned socket in the 
Unconnected state, instead of HostLookup.

In any case, in this backend we can safely use QTcpSocket directly. There 
should be no proxies in use for local KIO connections.

>Another point I recognized is in the method below where inited() was
>used to detect slave connection state, I think isConnected() would be
>better, but I may be wrong.

No, you're completely right. I didn't finish renaming all the old KDE 
2.x-style methods. Waldo forgive me, but we can do better now :-)

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070711/d4233dd7/attachment.sig>


More information about the kde-core-devel mailing list