[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kio_virtualfile/kio/kio
From:       Allan Sandfeld Jensen <kde () carewolf ! com>
Date:       2006-07-14 14:33:12
Message-ID: 1152887592.630941.20590.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 562283 by carewolf:

Redirection and writing


 M  +11 -1     slavefile.cpp  
 M  +42 -3     slavefile.h  
 M  +8 -2      slaveinterface.cpp  
 M  +3 -1      slaveinterface.h  


--- branches/work/kio_virtualfile/kio/kio/slavefile.cpp #562282:562283
@@ -44,6 +44,8 @@
 
 void SlaveFile::read(int size)
 {
+    if (!m_open) return;
+
     KIO_ARGS << size;
     m_slave->send( CMD_READ, packedArgs );
 }
@@ -51,18 +53,24 @@
 
 void SlaveFile::write(int size)
 {
+    if (!m_open) return;
+
     KIO_ARGS << size;
     m_slave->send( CMD_WRITE, packedArgs );
 }
 
 void SlaveFile::seek(int offset)
 {
+    if (!m_open) return;
+
     KIO_ARGS << offset;
     m_slave->send( CMD_SEEK, packedArgs) ;
 }
 
 void SlaveFile::close()
 {
+    if (!m_open) return;
+
     m_slave->send( CMD_CLOSE );
     // ###  close?
 }
@@ -77,7 +85,8 @@
 
 void SlaveFile::slotRedirection( const KUrl &url)
 {
-     kDebug(7007) << "SlaveFile::slotRedirection(" << url << ")" << endl;
+    kDebug(7007) << "SlaveFile::slotRedirection(" << url << ")" << endl;
+    emit redirection(this, m_redirectionURL);
 }
 
 void SlaveFile::slotMimetype( const QString& type )
@@ -93,6 +102,7 @@
 
 void SlaveFile::slotOpen( )
 {
+    m_open = true;
     emit open( this );
 }
 
--- branches/work/kio_virtualfile/kio/kio/slavefile.h #562282:562283
@@ -31,14 +31,40 @@
 Q_OBJECT
 
 public:
+    /**
+     * @internal
+     */
     SlaveFile(const KUrl& url, const QByteArray &packedArgs);
     ~SlaveFile();
 
+    /**
+     * Read
+     *
+     * The slave emits the data through data().
+     * @param size the requested amount of data
+     */
     void read( int size );
+
+    /**
+     * Write
+     *
+     * @param size the amount of data to write
+     */
     void write( int size );
 
+    /**
+     * Close
+     *
+     * Closes the file-slave
+     */
     void close();
 
+    /**
+     * Seek
+     *
+     * The slave emits position()
+     * @param offset the position from start to go to
+     */
     void seek( int offset );
 
     /**
@@ -59,8 +85,7 @@
 
     /**
      * Signals a redirection.
-     * Use to update the URL shown to the user.
-     * The redirection itself is handled internally.
+     * Follow this url manually
      * @param job the job that emitted this signal
      * @param url the new URL
      */
@@ -73,10 +98,24 @@
      */
     void mimetype( KIO::Job *job, const QString &type );
 
+    /**
+     * File is open and ready to receive commands
+     * @param job the job that emitted this signal
+     */
     void open(KIO::Job *job);
+
+    /**
+     * File is closed and will accept no more commands
+     * @param job the job that emitted this signal
+     */
     void close(KIO::Job *job);
 
-    void position( KIO::Job *job, KIO::filesize_t );
+    /**
+     * The file has reached this position. Emitted after seek.
+     * @param job the job that emitted this signal
+     * @param offeset the new position
+     */
+    void position( KIO::Job *job, KIO::filesize_t offset);
 
 private slots:
     virtual void slotRedirection( const KUrl &url);
--- branches/work/kio_virtualfile/kio/kio/slaveinterface.cpp #562282:562283
@@ -266,9 +266,15 @@
         }
         break;
     case MSG_CONNECTED:
-	emit connected();
-	break;
+        emit connected();
+        break;
 
+    case MSG_WRITTEN:
+    {
+        KIO::filesize_t size = readFilesize_t(stream);
+        emit written( size );
+    }
+    break;
     case INF_TOTAL_SIZE:
 	{
 	    KIO::filesize_t size = readFilesize_t(stream);
--- branches/work/kio_virtualfile/kio/kio/slaveinterface.h #562282:562283
@@ -80,7 +80,8 @@
    MSG_CANRESUME,
    MSG_AUTH_KEY, // deprecated.
    MSG_DEL_AUTH_KEY, // deprecated.
-   MSG_OPENED
+   MSG_OPENED,
+   MSG_WRITTEN
    // add new ones here once a release is done, to avoid breaking binary compatibility
  };
 
@@ -131,6 +132,7 @@
     void canResume( KIO::filesize_t );
 
     void open();
+    void written( KIO::filesize_t );
 
     ///////////
     // Info sent by the slave
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic