<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/101149/">http://git.reviewboard.kde.org/r/101149/</a>
     </td>
    </tr>
   </table>
   <br />








<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On April 18th, 2011, 12:43 p.m., <b>David Faure</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  



<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="http://git.reviewboard.kde.org/r/101149/diff/1/?file=14721#file14721line1766" style="color: black; font-weight: bold; text-decoration: underline;">kioslave/ftp/ftp.cpp</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">Ftp::StatusCode Ftp::ftpGet(int& iError, int iCopyFile, const KUrl& url, KIO::fileoffset_t llOffset)</pre></td>

  </tr>
 </tbody>




 
 



 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1766</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">  <span class="k">if</span> <span class="p">(</span><span class="n">m_data</span><span class="o">-></span><span class="n">bytesAvailable</span><span class="p">()</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span></pre></td>
  </tr>

 </tbody>

</table>

  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Maybe this should be "while we haven't read 1024 bytes", but of course the file could be smaller than that so it would have to check for that too.

What I mean is: I assume peek() doesn't wait, so if the first packet we get is 48 bytes, we have only 48 bytes. Don't know if this is a real problem in practice though, feel free to ignore this comment.</pre>
 </blockquote>



 <p>On April 18th, 2011, 4:27 p.m., <b>Dawit Alemayehu</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">No actually that is a good point. Perhaps a good compromise would be to wait for the 1024 bytes whenever the size of the content to be retrieved is known to be larger than 1024 bytes ? That way for the large enough files, we have a better success of getting a more accurate mime-type and for the others well we do the best we can. :) I will see what I can do about it. For the record, I did test this change with a small enough file, ftp://ftp.kde.org/pub/kde/README_UPLOAD, which happens to be only 404 bytes. Here is the log:

kio_ftp(2902) Ftp::copy: ftp "/pub/kde/README_UPLOAD" -> local file "/tmp/kde-dalemayehu/konqueroraj1566"
kio_ftp(2902) Ftp::ftpDataMode: want I has ^@
kio_ftp(2902) Ftp::ftpSendCmd: send>  TYPE I
kio_ftp(2902) Ftp::ftpResponse:     >  200 Switching to Binary mode.
kio_ftp(2902) Ftp::ftpResponse: resp>  200 Switching to Binary mode.
kio_ftp(2902) Ftp::ftpSendCmd: send>  SIZE /pub/kde/README_UPLOAD
kio_ftp(2902) Ftp::ftpResponse:     >  213 404
kio_ftp(2902) Ftp::ftpResponse: resp>  213 404
kio_ftp(2902) Ftp::ftpDataMode: want I has I
kio_ftp(2902) Ftp::ftpSendCmd: send>  PASV
kio_ftp(2902) Ftp::ftpResponse:     >  227 Entering Passive Mode (131,220,16,1,22,193).
kio_ftp(2902) Ftp::ftpResponse: resp>  227 Entering Passive Mode (131,220,16,1,22,193).
kio_ftp(2902) Ftp::ftpOpenPASVDataConnection: Connecting to  "131.220.16.1"  port  5825
kio_ftp(2902) Ftp::ftpSendCmd: send>  retr /pub/kde/README_UPLOAD
kio_ftp(2902) Ftp::ftpResponse:     >  150 Opening BINARY mode data connection for /pub/kde/README_UPLOAD (404 bytes).
kio_ftp(2902) Ftp::ftpResponse: resp>  150 Opening BINARY mode data connection for /pub/kde/README_UPLOAD (404 bytes).
kio_ftp(2902) Ftp::ftpOpenCommand: connected with remote.
kio_ftp(2902) Ftp::ftpGet: ftpGet: Emitting mimetype  "text/x-readme"
kio_ftp(2902) Ftp::ftpGet: ftpGet: starting with offset= 0
kio_ftp(2902) Ftp::ftpGet: ftpGet: done

I will see what I can do about improving the code as suggested...
</pre>
 </blockquote>







</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Yes, but careful with the case where the size is still "unknown" (I suppose it can happen).</pre>
<br />




<p>- David</p>


<br />
<p>On April 18th, 2011, 2:12 a.m., Dawit Alemayehu wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for kdelibs and David Faure.</div>
<div>By Dawit Alemayehu.</div>


<p style="color: grey;"><i>Updated April 18, 2011, 2:12 a.m.</i></p>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The attached patch changes the ftpGet function such that it emits the mime-type of the content it is about to read, before starting to read it. That way kio_ftp will work correctly if and when it is put on hold to be reused from another application. Note that the patch uses QIODevice::peek to achieve this goal.</pre>
  </td>
 </tr>
</table>





<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>kioslave/ftp/ftp.cpp <span style="color: grey">(64f43d8)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/101149/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>