[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 11:32:56
Message-ID: 1152185576.476090.31045.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 558965 by carewolf:
Compile..
M +2 -2 global.h
M +8 -0 job.cpp
M +10 -0 job.h
M +1 -1 slavebase.cpp
M +33 -16 slavefile.cpp
M +18 -8 slavefile.h
M +3 -2 slaveinterface.cpp
M +2 -2 slaveinterface.h
--- branches/work/kio_virtualfile/kio/kio/global.h #558964:558965
@@ -166,7 +166,7 @@
CMD_RESUMEANSWER = 'T', // 84
CMD_CONFIG = 'U', // 85
CMD_MULTI_GET = 'V', // 86
- CMD_SETLINKDEST = 'W' // 87
+ CMD_SETLINKDEST = 'W', // 87
CMD_OPEN = 'X' // 88
// Add new ones here once a release is done, to avoid breaking binary compatibility.
// Note that protocol-specific commands shouldn't be added here, but should use special.
@@ -180,7 +180,7 @@
CMD_WRITE = 129,
CMD_SEEK = 131,
CMD_CLOSE = 134
- }
+ };
/**
* Error codes that can be emitted by KIO.
--- branches/work/kio_virtualfile/kio/kio/job.cpp #558964:558965
@@ -61,6 +61,7 @@
#include "kmimemagic.h"
#include "kprotocolinfo.h"
#include "kprotocolmanager.h"
+#include "slavefile.h"
#include "kio/observer.h"
@@ -1026,6 +1027,13 @@
return job;
}
+SlaveFile *KIO::open( const KUrl& url )
+{
+ SlaveFile * job = new SlaveFile( url );
+ job->open();
+ return job;
+}
+
class PostErrorJob : public TransferJob
{
public:
--- branches/work/kio_virtualfile/kio/kio/job.h #558964:558965
@@ -26,6 +26,7 @@
namespace KIO {
+ class SlaveFile;
/**
* Creates a single directory.
@@ -188,6 +189,15 @@
KIO_EXPORT TransferJob *get( const KUrl& url, bool reload=false, bool showProgressInfo = true );
/**
+ * Open ( read-only )
+ *
+ * The slave-file emits open()
+ * @param url the URL of the file
+ * @return the file-handle slave
+ */
+ KIO_EXPORT SlaveFile *open( const KUrl& url );
+
+ /**
* Put (a.k.a. write)
*
* @param url Where to write data.
--- branches/work/kio_virtualfile/kio/kio/slavebase.cpp #558964:558965
@@ -401,7 +401,7 @@
if (!mOutgoingMetaData.isEmpty())
sendMetaData();
slaveWriteError = false;
- m_pConnection->send( MSG_FILE, fd );
+ m_pConnection->send( MSG_OPENED );
if (slaveWriteError) exit();
}
--- branches/work/kio_virtualfile/kio/kio/slavefile.cpp #558964:558965
@@ -17,12 +17,26 @@
* Boston, MA 02110-1301, USA.
*
**/
+
+#include "kio/slaveinterface.h"
+#include "kio/slavebase.h"
+#include "kio/connection.h"
+#include "kio/scheduler.h"
+#include "kio/slavefile.h"
+#include "kio/slave.h"
+
+#include <QTimer>
+#include <kdebug.h>
+
+
using namespace KIO;
+#define KIO_ARGS QByteArray packedArgs; QDataStream stream( &packedArgs, QIODevice::WriteOnly ); stream
+
SlaveFile::SlaveFile( const KUrl& url )
- : m_url(url);
+ : Job(false), m_url(url), m_open(false)
{
- if (!m_url.isValid())
+ if (!m_url.isValid() || m_url.hasSubUrl())
{
setError( ERR_MALFORMED_URL );
setErrorText( m_url.url() );
@@ -30,16 +44,9 @@
return;
}
- if (m_url.hasSubUrl())
- {
- KUrl::List list = KUrl::split(m_url);
- list.removeLast();
- m_subUrl = KUrl::join(list);
- //kDebug(7007) << "New URL = " << m_url.url() << endl;
- //kDebug(7007) << "Sub URL = " << m_subUrl.url() << endl;
- }
+ connect(this, SIGNAL(open()), SLOT(opened()));
- Scheduler::doJob(this);
+// Scheduler::doJob(this);
}
SlaveFile::~SlaveFile()
@@ -55,23 +62,28 @@
void SlaveFile::slaveDone()
{
if (!m_slave) return;
- disconnect(m_slave); // Remove all signals between slave and job
+// 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;
m_slave->send( CMD_READ, packedArgs );
}
-/*
+
void SlaveFile::write(int size)
{
KIO_ARGS << size;
- m_slave->send( CMD_READ, packedArgs );
-}*/
+ m_slave->send( CMD_WRITE, packedArgs );
+}
void SlaveFile::seek(int offset)
{
@@ -83,4 +95,9 @@
{
m_slave->send( CMD_CLOSE );
// ### close?
-}
\ No newline at end of file
+}
+
+void SlaveFile::opened()
+{
+ m_open = true;
+}
--- branches/work/kio_virtualfile/kio/kio/slavefile.h #558964:558965
@@ -18,6 +18,12 @@
*
**/
+#ifndef __slavefile_h
+#define __slavefile_h
+
+#include <kurl.h>
+#include <kio/jobclasses.h>
+
namespace KIO {
class KIO_EXPORT SlaveFile : public Job
@@ -28,18 +34,15 @@
SlaveFile(const KUrl& url);
~SlaveFile();
- void stream();
- void stop();
+ void open();
- void read();
+ void read( int size );
+ void write( int size );
void close();
- void seek();
+ void seek( int offset );
- void lock();
- void unlock();
-
/**
* @internal
* Called by the scheduler when a slave gets to
@@ -58,8 +61,15 @@
*/
Slave *slave() const { return m_slave; }
+private slots:
+ void opened();
+
protected:
Slave * m_slave;
KUrl m_url;
+ bool m_open;
+};
-}
+} // namespace
+
+#endif
--- branches/work/kio_virtualfile/kio/kio/slaveinterface.cpp #558964:558965
@@ -210,9 +210,10 @@
case MSG_DATA_REQ:
emit dataReq();
break;
- case MSG_FILE:
- emit file( rawdata );
+ case MSG_OPENED: {
+ emit open();
break;
+ }
case MSG_FINISHED:
//kDebug(7007) << "Finished [this = " << this << "]" << endl;
d->offset = 0;
--- branches/work/kio_virtualfile/kio/kio/slaveinterface.h #558964:558965
@@ -79,7 +79,7 @@
MSG_CANRESUME,
MSG_AUTH_KEY, // deprecated.
MSG_DEL_AUTH_KEY, // deprecated.
- MSG_FILE
+ MSG_OPENED
// add new ones here once a release is done, to avoid breaking binary compatibility
};
@@ -129,7 +129,7 @@
void canResume( KIO::filesize_t );
- void file( void* );
+ void open();
///////////
// 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