[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-06 16:51:33
Message-ID: 1152204693.531727.11365.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 559135 by carewolf:
Somewhat working KIO::open
M +4 -4 global.h
M +3 -2 job.cpp
M +8 -2 slavebase.cpp
M +2 -0 slavebase.h
M +52 -34 slavefile.cpp
M +43 -21 slavefile.h
M +6 -0 slaveinterface.cpp
M +3 -1 slaveinterface.h
--- branches/work/kio_virtualfile/kio/kio/global.h #559134:559135
@@ -176,10 +176,10 @@
* Commands that can be invoked on a slave-file.
*/
enum FileCommand {
- CMD_READ = 128,
- CMD_WRITE = 129,
- CMD_SEEK = 131,
- CMD_CLOSE = 134
+ CMD_READ = 90,
+ CMD_WRITE = 91,
+ CMD_SEEK = 92,
+ CMD_CLOSE = 93
};
/**
--- branches/work/kio_virtualfile/kio/kio/job.cpp #559134:559135
@@ -1029,8 +1029,9 @@
SlaveFile *KIO::open( const KUrl& url )
{
- SlaveFile * job = new SlaveFile( url );
- job->open();
+ // Send decoded path and encoded query
+ KIO_ARGS << url;
+ SlaveFile * job = new SlaveFile( url, packedArgs );
return job;
}
--- branches/work/kio_virtualfile/kio/kio/slavebase.cpp #559134:559135
@@ -510,6 +510,12 @@
// d->processed_size = _bytes;
}
+void SlaveBase::position( KIO::filesize_t _pos )
+{
+ KIO_DATA << KIO_FILESIZE_T(_pos);
+ m_pConnection->send( INF_POSITION, data );
+}
+
void SlaveBase::processedPercent( float /* percent */ )
{
kDebug(7019) << "SlaveBase::processedPercent: STUB" << endl;
@@ -742,7 +748,7 @@
void SlaveBase::get(KUrl const & )
{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_GET)); }
void SlaveBase::open(KUrl const & )
-{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_GET)); }
+{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_OPEN)); }
void SlaveBase::mimetype(KUrl const &url)
{ get(url); }
void SlaveBase::rename(KUrl const &, KUrl const &, bool)
@@ -990,7 +996,7 @@
case CMD_OPEN:
{
stream >> url;
- get( url );
+ open( url );
} break;
case CMD_PUT:
{
--- branches/work/kio_virtualfile/kio/kio/slavebase.h #559134:559135
@@ -187,6 +187,8 @@
*/
void processedSize( KIO::filesize_t _bytes );
+ void position( KIO::filesize_t _pos );
+
/**
* Only use this if you can't know in advance the size of the
* copied data. For example, if you're doing variable bitrate
--- branches/work/kio_virtualfile/kio/kio/slavefile.cpp #559134:559135
@@ -33,45 +33,15 @@
#define KIO_ARGS QByteArray packedArgs; QDataStream stream( &packedArgs, QIODevice::WriteOnly ); stream
-SlaveFile::SlaveFile( const KUrl& url )
- : Job(false), m_url(url), m_open(false)
+SlaveFile::SlaveFile( const KUrl& url, const QByteArray &packedArgs )
+ : SimpleJob(url, CMD_OPEN, packedArgs, false), m_open(false)
{
- if (!m_url.isValid() || m_url.hasSubUrl())
- {
- setError( ERR_MALFORMED_URL );
- setErrorText( m_url.url() );
- QTimer::singleShot(0, this, SLOT(slotFinished()) );
- return;
- }
-
- connect(this, SIGNAL(open()), SLOT(opened()));
-
-// Scheduler::doJob(this);
}
SlaveFile::~SlaveFile()
{
- if (m_slave) // was running
- {
- kDebug(7007) << "SlaveFile::~SlaveFile: Killing running job in destructor!" << endl;
-// Scheduler::cancelJob( this ); ??
- m_slave = 0; // -> set to 0
- }
}
-void SlaveFile::slaveDone()
-{
- if (!m_slave) return;
-// disconnect(m_slave); // Remove all signals between slave and job
-// Scheduler::jobFinished( this, m_slave );
- m_slave = 0;
-}
-
-void SlaveFile::open()
-{
- m_slave->send( CMD_OPEN );
-}
-
void SlaveFile::read(int size)
{
KIO_ARGS << size;
@@ -97,7 +67,55 @@
// ### close?
}
-void SlaveFile::opened()
+// Slave sends data
+void SlaveFile::slotData( const QByteArray &_data)
{
- m_open = true;
+// kDebug(7007) << "SlaveFile::slotData(" << _data.size() << ")" << endl;
+// if(m_redirectionURL.isEmpty() || !m_redirectionURL.isValid() || error())
+ emit data( this, _data);
}
+
+void SlaveFile::slotRedirection( const KUrl &url)
+{
+ kDebug(7007) << "SlaveFile::slotRedirection(" << url << ")" << endl;
+}
+
+void SlaveFile::slotMimetype( const QString& type )
+{
+ m_mimetype = type;
+ emit mimetype( this, m_mimetype);
+}
+
+void SlaveFile::slotPosition( KIO::filesize_t pos )
+{
+ emit position( this, pos);
+}
+
+void SlaveFile::slotOpen( )
+{
+ emit open();
+}
+
+void SlaveFile::start(Slave *slave)
+{
+ connect( slave, SIGNAL( data( const QByteArray & ) ),
+ SLOT( slotData( const QByteArray & ) ) );
+
+ connect( slave, SIGNAL( redirection(const KUrl &) ),
+ SLOT( slotRedirection(const KUrl &) ) );
+
+ connect( slave, SIGNAL(mimeType( const QString& ) ),
+ SLOT( slotMimetype( const QString& ) ) );
+
+ connect( slave, SIGNAL(open() ),
+ SLOT( slotOpen() ) );
+
+ connect( slave, SIGNAL(position(KIO::filesize_t) ),
+ SLOT( slotPosition(KIO::filesize_t) ) );
+
+ SimpleJob::start(slave);
+
+}
+
+#include "slavefile.moc"
+
--- branches/work/kio_virtualfile/kio/kio/slavefile.h #559134:559135
@@ -26,16 +26,14 @@
namespace KIO {
-class KIO_EXPORT SlaveFile : public Job
+class KIO_EXPORT SlaveFile : public SimpleJob
{
- Q_OBJECT
+Q_OBJECT
public:
- SlaveFile(const KUrl& url);
+ SlaveFile(const KUrl& url, const QByteArray &packedArgs);
~SlaveFile();
- void open();
-
void read( int size );
void write( int size );
@@ -44,30 +42,54 @@
void seek( int offset );
/**
- * @internal
- * Called by the scheduler when a slave gets to
- * work on this job.
- **/
- virtual void start( Slave *slave );
+ * @internal
+ * Called by the scheduler when a @p slave gets to
+ * work on this job.
+ * @param slave the slave that starts working on this job
+ */
+ virtual void start(Slave *slave);
+
+signals:
/**
- * @internal
- * Called to detach a slave from a job.
- **/
- void slaveDone();
+ * Data from the slave has arrived.
+ * @param job the job that emitted this signal
+ * @param data data received from the slave.
+ */
+ void data( KIO::Job *job, const QByteArray &data );
/**
- * @internal
- * Slave in use by this job.
- */
- Slave *slave() const { return m_slave; }
+ * Signals a redirection.
+ * Use to update the URL shown to the user.
+ * The redirection itself is handled internally.
+ * @param job the job that emitted this signal
+ * @param url the new URL
+ */
+ void redirection( KIO::Job *job, const KUrl &url );
+ /**
+ * Mimetype determined.
+ * @param job the job that emitted this signal
+ * @param type the mime type
+ */
+ void mimetype( KIO::Job *job, const QString &type );
+
+ void open();
+
+ void position( KIO::Job *job, KIO::filesize_t );
+
private slots:
- void opened();
+ virtual void slotRedirection( const KUrl &url);
+// virtual void slotFinished();
+ virtual void slotData( const QByteArray &data);
+ virtual void slotMimetype( const QString &mimetype );
+ virtual void slotOpen( );
+ virtual void slotPosition( KIO::filesize_t );
protected:
- Slave * m_slave;
- KUrl m_url;
bool m_open;
+ KUrl m_redirectionURL;
+ KUrl::List m_redirectionList;
+ QString m_mimetype;
};
} // namespace
--- branches/work/kio_virtualfile/kio/kio/slaveinterface.cpp #559134:559135
@@ -290,6 +290,12 @@
d->filesize = size;
}
break;
+ case INF_POSITION:
+ {
+ KIO::filesize_t pos = readFilesize_t(stream);
+ emit position( pos );
+ }
+ break;
case INF_SPEED:
stream >> ul;
d->slave_calcs_speed = true;
--- branches/work/kio_virtualfile/kio/kio/slaveinterface.h #559134:559135
@@ -54,7 +54,8 @@
INF_INFOMESSAGE,
INF_META_DATA,
INF_NETWORK_STATUS,
- INF_MESSAGEBOX
+ INF_MESSAGEBOX,
+ INF_POSITION
// add new ones here once a release is done, to avoid breaking binary compatibility
};
@@ -138,6 +139,7 @@
void totalSize( KIO::filesize_t );
void processedSize( KIO::filesize_t );
void redirection( const KUrl& );
+ void position( KIO::filesize_t );
void speed( unsigned long );
void errorPage();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic