# class ForwardingSlaveBase

### abstract

Module | kio
Namespace | KIO
Class | ForwardingSlaveBase
Inherits | QObject,KIO::SlaveBase

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

- ForwardingSlaveBase (protocol, poolSocket, appSocket)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  protocol | QByteArray |
  poolSocket | QByteArray |
  appSocket | QByteArray |

- chmod (url, permissions)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |
  permissions | int |

- copy (src, dest, permissions, flags)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  src | KUrl |
  dest | KUrl |
  permissions | int |
  flags | KIO.JobFlags |

- del (url, isfile)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |
  isfile | bool |

- get (url)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |

- listDir (url)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |

- mimetype (url)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |

- mkdir (url, permissions)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |
  permissions | int |

- prepareUDSEntry (entry, listing)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  entry | KIO.UDSEntry |
  listing | bool | 0

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

  entry - the UDSEntry to post-process

  listing - indicate if this entry it created during a listDir operation

- processedUrl ( )

  returns KUrl

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

- put (url, permissions, flags)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |
  permissions | int |
  flags | KIO.JobFlags |

- rename (src, dest, flags)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  src | KUrl |
  dest | KUrl |
  flags | KIO.JobFlags |

- requestedUrl ( )

  returns KUrl

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

- rewriteUrl (url, newURL)

  returns bool
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |
  newURL | KUrl |

  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 cancel the current slave operation.

  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 (url, mtime)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |
  mtime | QDateTime |

- stat (url)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |

- symlink (target, dest, flags)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  target | QString |
  dest | KUrl |
  flags | KIO.JobFlags |