[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-17 12:40:12
Message-ID: 1153140012.195643.21673.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 563377 by carewolf:
Open with access
M +19 -3 filejob.cpp
M +17 -8 filejob.h
M +4 -4 job.cpp
M +3 -2 job.h
M +4 -4 slavebase.cpp
M +5 -5 slavebase.h
--- branches/work/kio_virtualfile/kio/kio/filejob.cpp #563376:563377
@@ -22,9 +22,10 @@
#include "kio/slavebase.h"
#include "kio/connection.h"
#include "kio/scheduler.h"
-#include "kio/slavefile.h"
#include "kio/slave.h"
+#include "kio/filejob.h"
+
#include <QTimer>
#include <kdebug.h>
@@ -34,7 +35,7 @@
#define KIO_ARGS QByteArray packedArgs; QDataStream stream( &packedArgs, QIODevice::WriteOnly ); stream
FileJob::FileJob( const KUrl& url, const QByteArray &packedArgs )
- : SimpleJob(url, CMD_OPEN, packedArgs, false), m_open(false)
+ : SimpleJob(url, CMD_OPEN, packedArgs, false), m_open(false), m_length(0)
{
}
@@ -74,6 +75,13 @@
// ### close?
}
+KIO::filesize_t FileJob::length()
+{
+ if (!m_open) return 0;
+
+ return m_length;
+}
+
// Slave sends data
void FileJob::slotData( const QByteArray &_data)
{
@@ -83,7 +91,7 @@
void FileJob::slotRedirection( const KUrl &url)
{
kDebug(7007) << "FileJob::slotRedirection(" << url << ")" << endl;
- emit redirection(this, m_redirectionURL);
+ emit redirection(this, url);
}
void FileJob::slotMimetype( const QString& type )
@@ -97,6 +105,11 @@
emit position( this, pos);
}
+void FileJob::slotTotalSize( KIO::filesize_t _length )
+{
+ m_length = _length;
+}
+
void FileJob::slotOpen( )
{
m_open = true;
@@ -129,6 +142,9 @@
connect( slave, SIGNAL(position(KIO::filesize_t) ),
SLOT( slotPosition(KIO::filesize_t) ) );
+ connect( slave, SIGNAL(totalSize(KIO::filesize_t) ),
+ SLOT( slotTotalSize(KIO::filesize_t) ) );
+
SimpleJob::start(slave);
}
--- branches/work/kio_virtualfile/kio/kio/filejob.h #563376:563377
@@ -45,7 +45,7 @@
~FileJob();
/**
- * Read
+ * Read block
*
* The slave emits the data through data().
* @param size the requested amount of data
@@ -53,11 +53,11 @@
void read( int size );
/**
- * Write
+ * Write block
*
- * @param size the amount of data to write
+ * @param data the data to write
*/
- void write( int size );
+ void write( const QByteArray &data );
/**
* Close
@@ -75,6 +75,13 @@
void seek( int offset );
/**
+ * Length
+ *
+ * @return the file length
+ */
+ KIO::filesize_t length();
+
+ /**
* @internal
* Called by the scheduler when a @p slave gets to
* work on this job.
@@ -91,8 +98,8 @@
void data( KIO::Job *job, const QByteArray &data );
/**
- * Signals a redirection.
- * Follow this url manually
+ * Signals the file is a redirection.
+ * Follow this url manually to reach data
* @param job the job that emitted this signal
* @param url the new URL
*/
@@ -106,7 +113,8 @@
void mimetype( KIO::Job *job, const QString &type );
/**
- * File is open and ready to receive commands
+ * File is open, metadata has been determined and the
+ * file-slave is ready to receive commands.
* @param job the job that emitted this signal
*/
void open(KIO::Job *job);
@@ -126,16 +134,17 @@
private slots:
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 slotFinished( );
virtual void slotPosition( KIO::filesize_t );
+ virtual void slotTotalSize( KIO::filesize_t );
protected:
bool m_open;
QString m_mimetype;
+ KIO::filesize_t m_length;
};
} // namespace
--- branches/work/kio_virtualfile/kio/kio/job.cpp #563376:563377
@@ -61,7 +61,7 @@
#include "kmimemagic.h"
#include "kprotocolinfo.h"
#include "kprotocolmanager.h"
-#include "slavefile.h"
+#include "filejob.h"
#include "kio/observer.h"
@@ -1092,11 +1092,11 @@
return job;
}
-SlaveFile *KIO::open( const KUrl& url )
+FileJob *KIO::open( const KUrl& url, int access )
{
// Send decoded path and encoded query
- KIO_ARGS << url;
- SlaveFile * job = new SlaveFile( url, packedArgs );
+ KIO_ARGS << url << access;
+ FileJob * job = new FileJob( url, packedArgs );
return job;
}
--- branches/work/kio_virtualfile/kio/kio/job.h #563376:563377
@@ -189,13 +189,14 @@
KIO_EXPORT TransferJob *get( const KUrl& url, bool reload=false, bool showProgressInfo = true );
/**
- * Open ( stepwise I/O )
+ * Open ( random access I/O )
*
* The file-job emits open() when opened
* @param url the URL of the file
+ * @param access the access priveleges (1 - ReadOnly, 2 - WriteOnly, 3 - Read/Write)
* @return the file-handling job
*/
- KIO_EXPORT FileJob *open( const KUrl& url );
+ KIO_EXPORT FileJob *open( const KUrl& url, int access );
/**
* Put (a.k.a. write)
--- branches/work/kio_virtualfile/kio/kio/slavebase.cpp #563376:563377
@@ -396,7 +396,7 @@
m_pConnection->send( MSG_DATA_REQ );
}
-void SlaveBase::file( void* fd )
+void SlaveBase::opened()
{
if (!mOutgoingMetaData.isEmpty())
sendMetaData();
@@ -753,7 +753,7 @@
{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_LISTDIR)); }
void SlaveBase::get(KUrl const & )
{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_GET)); }
-void SlaveBase::open(KUrl const & )
+void SlaveBase::open(KUrl const &, int access )
{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_OPEN)); }
void SlaveBase::mimetype(KUrl const &url)
{ get(url); }
@@ -1004,8 +1004,8 @@
} break;
case CMD_OPEN:
{
- stream >> url;
- open( url );
+ stream >> url >> i;
+ open( url, i );
} break;
case CMD_PUT:
{
--- branches/work/kio_virtualfile/kio/kio/slavebase.h #563376:563377
@@ -91,11 +91,10 @@
void dataReq( );
/**
- * Sends file in the slave to the job (i.e. in open).
- *
- * @param fd the filehandle
+ * open succedes
+ * @see open
*/
- void file( void* fd);
+ void opened();
/**
* Call to signal an error.
@@ -378,8 +377,9 @@
* open.
* @param url the full url for this request. Host, port and user of the URL
* can be assumed to be the same as in the last setHost() call.
+ * @param access 1 - rdonly, 2 - wronly or 3 - rdwr
*/
- virtual void open( const KUrl& url );
+ virtual void open( const KUrl& url, int access );
/**
* put, i.e. write data into a file.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic