KIO.ForwardingSlaveBase

KDE 4.5 PyKDE API Reference

- KDE's Python API

# ForwardingSlaveBase Class Reference

`from PyKDE4.kio import *`

Inherits: QObject,KIO.SlaveBase
Namespace: KIO

## Detailed Description

This class should be used as a base for ioslaves acting as a forwarder to other ioslaves. It has been designed to support only local filesystem like ioslaves.

If the resulting ioslave should be a simple proxy, you only need to implement the ForwardingSlaveBase.rewriteUrl() method.

For more advanced behavior, the classic ioslave methods should be reimplemented, because their default behavior in this class is to forward using the ForwardingSlaveBase.rewriteUrl() method.

A possible code snippet for an advanced stat() behavior would look like this in the child class:

         void ChildProtocol.stat(const KUrl &url)
         {
             bool is_special = false;

             // Process the URL to see if it should have
             // a special treatment

             if ( is_special )
             {
                 // Handle the URL ourselves
                 KIO.UDSEntry entry;
                 // Fill entry with UDSAtom instances
                 statEntry(entry);
                 finished();
             }
             else
             {
                 // Setup the ioslave internal state if
                 // required by ChildProtocol.rewriteUrl()
                 ForwardingSlaveBase.stat(url);
             }
         }

Of course in this case, you surely need to reimplement listDir() and get() accordingly.

If you want view on directories to be correctly refreshed when something changes on a forwarded URL, you'll need a companion kded module to emit the KDirNotify Files*() D-Bus signals.

This class was initially used for media:/ ioslave. This ioslave code and the MediaDirNotify class of its companion kded module can be a good source of inspiration.

See also:
  ForwardingSlaveBase.rewriteUrl()

Author:
  Kevin Ottens <ervin@ipsquad.net>

## Methods
| __init__ (self, QByteArray protocol, QByteArray poolSocket, QByteArray appSocket)
| chmod (self, KUrl url, int permissions)
| copy (self, KUrl src, KUrl dest, int permissions, KIO.JobFlags flags)
| del_ (self, KUrl url, bool isfile)
| get (self, KUrl url)
| listDir (self, KUrl url)
| mimetype (self, KUrl url)
| mkdir (self, KUrl url, int permissions)
| prepareUDSEntry (self, KIO.UDSEntry entry, bool listing=0)
KUrl | processedUrl (self)
| put (self, KUrl url, int permissions, KIO.JobFlags flags)
| rename (self, KUrl src, KUrl dest, KIO.JobFlags flags)
KUrl | requestedUrl (self)
bool | rewriteUrl (self, KUrl url, KUrl newURL)
| setModificationTime (self, KUrl url, QDateTime mtime)
| stat (self, KUrl url)
| symlink (self, QString target, KUrl dest, KIO.JobFlags flags)

## Method Documentation

__init__ | ( | self, |
|  | QByteArray | protocol,
|  | QByteArray | poolSocket,
|  | QByteArray | appSocket
| ) |  |  |

chmod | ( | self, |
|  | KUrl | url,
|  | int | permissions
| ) |  |  |

copy | ( | self, |
|  | KUrl | src,
|  | KUrl | dest,
|  | int | permissions,
|  | KIO.JobFlags | flags
| ) |  |  |

del_ | ( | self, |
|  | KUrl | url,
|  | bool | isfile
| ) |  |  |

get | ( | self, |
|  | KUrl | url
| ) |  |  |

listDir | ( | self, |
|  | KUrl | url
| ) |  |  |

mimetype | ( | self, |
|  | KUrl | url
| ) |  |  |

mkdir | ( | self, |
|  | KUrl | url,
|  | int | permissions
| ) |  |  |

prepareUDSEntry | ( | self, |
|  | KIO.UDSEntry | entry,
|  | bool | listing=0
| ) |  |  |

Allow to modify a UDSEntry before it's sent to the ioslave endpoint. This is the default implementation working in most cases, but sometimes you could make use of more forwarding black magic (for example dynamically transform any desktop file into a fake directory...)

Parameters:

  | entry | the UDSEntry to post-process
  | listing | indicate if this entry it created during a listDir operation

KUrl processedUrl | ( |  | self ) |

Return the URL being processed by the ioslave Only access it inside prepareUDSEntry()

put | ( | self, |
|  | KUrl | url,
|  | int | permissions,
|  | KIO.JobFlags | flags
| ) |  |  |

rename | ( | self, |
|  | KUrl | src,
|  | KUrl | dest,
|  | KIO.JobFlags | flags
| ) |  |  |

KUrl requestedUrl | ( |  | self ) |

Return the URL asked to the ioslave Only access it inside prepareUDSEntry()

bool rewriteUrl | ( | self, |
|  | KUrl | url,
|  | KUrl | newURL
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Rewrite an url to its forwarded counterpart. It should return true if everything was ok, and false otherwise.

If a problem is detected it's up to this method to trigger error() before returning. Returning false silently cancels the current slave operation.

Parameters:

  | url | The URL as given during the slave call
  | newURL | The new URL to forward the slave call to

Returns:
  true if the given url could be correctly rewritten

setModificationTime | ( | self, |
|  | KUrl | url,
|  | QDateTime | mtime
| ) |  |  |

stat | ( | self, |
|  | KUrl | url
| ) |  |  |

symlink | ( | self, |
|  | QString | target,
|  | KUrl | dest,
|  | KIO.JobFlags | flags
| ) |  |  |