summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tdeio/tdeio/netaccess.cpp38
-rw-r--r--tdeio/tdeio/netaccess.h17
-rw-r--r--tdeio/tdeio/tdefileitem.cpp30
3 files changed, 71 insertions, 14 deletions
diff --git a/tdeio/tdeio/netaccess.cpp b/tdeio/tdeio/netaccess.cpp
index cbab6684e..2867c3cf7 100644
--- a/tdeio/tdeio/netaccess.cpp
+++ b/tdeio/tdeio/netaccess.cpp
@@ -190,6 +190,12 @@ bool NetAccess::exists( const KURL & url, bool source, TQWidget* window )
return kioNet.statInternal( url, 0 /*no details*/, source, window );
}
+KURL NetAccess::localURL(const KURL& url, TQWidget* window)
+{
+ NetAccess kioNet;
+ return kioNet.localURLInternal( url, window );
+}
+
bool NetAccess::stat( const KURL & url, TDEIO::UDSEntry & entry )
{
return NetAccess::stat( url, entry, 0 );
@@ -347,6 +353,17 @@ bool NetAccess::statInternal( const KURL & url, int details, bool source,
return bJobOK;
}
+KURL NetAccess::localURLInternal( const KURL & url, TQWidget* window )
+{
+ m_localURL = url;
+ TDEIO::LocalURLJob* job = TDEIO::localURL(url);
+ job->setWindow (window);
+ connect(job, TQT_SIGNAL( localURL(TDEIO::Job*, const KURL&, bool) ),
+ this, TQT_SLOT( slotLocalURL(TDEIO::Job*, const KURL&, bool) ));
+ enter_loop();
+ return m_localURL;
+}
+
bool NetAccess::delInternal( const KURL & url, TQWidget* window )
{
bJobOK = true; // success unless further error occurs
@@ -389,6 +406,12 @@ void NetAccess::slotMimetype( TDEIO::Job *, const TQString & type )
m_mimetype = type;
}
+void NetAccess::slotLocalURL(TDEIO::Job*, const KURL & url, bool)
+{
+ m_localURL = url;
+ tqApp->exit_loop();
+}
+
TQString NetAccess::fish_executeInternal(const KURL & url, const TQString command, TQWidget* window)
{
TQString target, remoteTempFileName, resultData;
@@ -503,25 +526,28 @@ void NetAccess::slotResult( TDEIO::Job * job )
{
lastErrorCode = job->error();
bJobOK = !job->error();
- if ( !bJobOK )
- {
- if ( !lastErrorMsg )
+ if ( !bJobOK ) {
+ if ( !lastErrorMsg ) {
lastErrorMsg = new TQString;
+ }
*lastErrorMsg = job->errorString();
}
- if ( job->isA("TDEIO::StatJob") )
+ if ( job->isA("TDEIO::StatJob") ) {
m_entry = static_cast<TDEIO::StatJob *>(job)->statResult();
+ }
- if ( m_metaData )
+ if ( m_metaData ) {
*m_metaData = job->metaData();
+ }
tqApp->exit_loop();
}
void NetAccess::slotData( TDEIO::Job*, const TQByteArray& data )
{
- if ( data.isEmpty() )
+ if ( data.isEmpty() ) {
return;
+ }
unsigned offset = m_data.size();
m_data.resize( offset + data.size() );
diff --git a/tdeio/tdeio/netaccess.h b/tdeio/tdeio/netaccess.h
index 82769be73..7dde61385 100644
--- a/tdeio/tdeio/netaccess.h
+++ b/tdeio/tdeio/netaccess.h
@@ -248,6 +248,20 @@ public:
static bool move( const KURL::List& src, const KURL& target, TQWidget* window = 0L );
/**
+ * Returns the output of the localURL TDEIO job.
+ *
+ * @param url the URL we are testing
+ * @param window main window associated with this job. This is used to
+ * automatically cache and discard authentication information
+ * as needed. If NULL, authentication information will be
+ * cached only for a short duration after which the user will
+ * again be prompted for passwords as needed.
+ * @return the local URL for the given URL
+ * @since R14
+ */
+ static KURL localURL(const KURL& url, TQWidget* window);
+
+ /**
* Tests whether a URL exists.
*
* @param url the URL we are testing
@@ -493,6 +507,7 @@ private:
bool dircopyInternal(const KURL::List& src, const KURL& target,
TQWidget* window, bool move);
bool statInternal(const KURL & url, int details, bool source, TQWidget* window = 0);
+ KURL localURLInternal( const KURL & url, TQWidget* window = 0);
bool delInternal(const KURL & url, TQWidget* window = 0);
bool mkdirInternal(const KURL & url, int permissions, TQWidget* window = 0);
@@ -516,12 +531,14 @@ private:
private slots:
void slotResult( TDEIO::Job * job );
void slotMimetype( TDEIO::Job * job, const TQString & type );
+ void slotLocalURL(TDEIO::Job*, const KURL&, bool);
void slotData( TDEIO::Job*, const TQByteArray& );
void slotRedirection( TDEIO::Job*, const KURL& );
private:
UDSEntry m_entry;
TQString m_mimetype;
+ KURL m_localURL;
TQByteArray m_data;
KURL m_url;
TQMap<TQString, TQString> *m_metaData;
diff --git a/tdeio/tdeio/tdefileitem.cpp b/tdeio/tdeio/tdefileitem.cpp
index 071153208..16f37f0d3 100644
--- a/tdeio/tdeio/tdefileitem.cpp
+++ b/tdeio/tdeio/tdefileitem.cpp
@@ -49,6 +49,8 @@
#include <kmimetype.h>
#include <krun.h>
+#include "netaccess.h"
+
#ifdef HAVE_ELFICON
#include "tdelficon.h"
#endif // HAVE_ELFICON
@@ -234,8 +236,9 @@ void KFileItem::readUDSEntry( bool _urlIsDirectory )
case TDEIO::UDS_URL:
UDS_URL_seen = true;
m_url = KURL((*it).m_str);
- if ( m_url.isLocalFile() )
+ if ( m_url.isLocalFile() ) {
m_bIsLocalURL = true;
+ }
break;
case TDEIO::UDS_MIME_TYPE:
@@ -301,6 +304,7 @@ void KFileItem::setURL( const KURL &url )
{
m_url = url;
setName( url.fileName() );
+ m_bIsLocalURL = m_url.isLocalFile();
}
void KFileItem::setListerURL( const KURL &url )
@@ -339,20 +343,30 @@ TQString KFileItem::linkDest() const
TQString KFileItem::localPath() const
{
- if ( m_bIsLocalURL )
- {
+ if ( m_bIsLocalURL ) {
return m_url.path();
}
- else
- {
- if (&m_entry == NULL) return TQString::null;
+ else {
+ if (&m_entry == NULL) {
+ return TQString::null;
+ }
// Extract the local path from the TDEIO::UDSEntry
TDEIO::UDSEntry::ConstIterator it = m_entry.begin();
const TDEIO::UDSEntry::ConstIterator end = m_entry.end();
- for( ; it != end; ++it )
- if ( (*it).m_uds == TDEIO::UDS_LOCAL_PATH )
+ for( ; it != end; ++it ) {
+ if ( (*it).m_uds == TDEIO::UDS_LOCAL_PATH ) {
return (*it).m_str;
+ }
+ }
+ }
+
+ // If we still do not have a local URL, use the lister URL
+ // Without this, Trash functionality will not work with the media:/ tdeioslave!
+ if ((!m_url.isLocalFile())/* && (m_url.protocol() == "media")*/) {
+ if (m_listerURL.isLocalFile()) {
+ return m_listerURL.path();
+ }
}
return TQString::null;