KNetworkMounts

Search for usage in LXR

#include <KNetworkMounts>

Inheritance diagram for KNetworkMounts:

Public Types

enum  KNetworkMountOption {
  LowSideEffectsOptimizations , MediumSideEffectsOptimizations , StrongSideEffectsOptimizations , KDirWatchDontAddWatches ,
  SymlinkPathsUseCache
}
 
enum  KNetworkMountsType {
  NfsPaths , SmbPaths , SymlinkDirectory , SymlinkToNetworkMount ,
  Any
}
 

Public Member Functions

void addPath (const QString &path, KNetworkMountsType type)
 
QString canonicalSymlinkPath (const QString &path)
 
void clearCache ()
 
bool isEnabled () const
 
bool isOptionEnabled (const KNetworkMountOption option, const bool defaultValue=false) const
 
bool isOptionEnabledForPath (const QString &path, KNetworkMountOption option)
 
bool isSlowPath (const QString &path, KNetworkMountsType type=Any)
 
QStringList paths (KNetworkMountsType type=Any) const
 
void setEnabled (bool value)
 
void setOption (const KNetworkMountOption option, const bool value)
 
void setPaths (const QStringList &paths, KNetworkMountsType type)
 
void sync ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static KNetworkMountsself ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

Performance control on network mounts.

This class provides methods for deciding whether operations on slow network mounts should be performed or not.

Configuration is read from a configuration file network_mounts in the user's QStandardPaths::ConfigLocation. This file can be filled by using the network mounts performance configuration module or directly via setEnabled, setPaths, addPath and setOption

static KNetworkMounts * self()
Returns (and creates if necessary) the singleton instance.
void setEnabled(bool value)
Switch the performance optimizations on or off.
@ LowSideEffectsOptimizations
Don't run KDiskFreeSpaceInfo if slow path.
@ SmbPaths
SMB paths.
@ NfsPaths
NFS paths.
void setOption(const KNetworkMountOption option, const bool value)
Switch a performance option on or off.
void setPaths(const QStringList &paths, KNetworkMountsType type)
Set the paths for which optimizations are to take place.
void addPath(const QString &path, KNetworkMountsType type)
Add a path for which optimizations are to take place.

Use KNetworkMounts like this to check if the given url is on a configured slow path and the KNetworkMountOption LowSideEffectsOptimizations is enabled:

{
// skip operations which are slow on the given url if
// KNetworkMountOption LowSideEffectsOptimizations is enabled
} else {
// given url is not configured being slow or the KNetworkMountOption
// LowSideEffectsOptimizations is not enabled
}
bool isOptionEnabledForPath(const QString &path, KNetworkMountOption option)
Query if path is configured to be a slow path and option is enabled.

If called for the first time, this creates a singleton instance and reads the config file. Subsequent calls just use this instance without reading the config file again.

Author
Robert Hoffmann rober.nosp@m.t@ro.nosp@m.berth.nosp@m.offm.nosp@m.ann.d.nosp@m.e
Since
5.85

Definition at line 58 of file knetworkmounts.h.

Member Enumeration Documentation

◆ KNetworkMountOption

The KNetworkMountOption enum.

Uses are:

Enumerator
LowSideEffectsOptimizations 

Don't run KDiskFreeSpaceInfo if slow path.


Don't check for manually mounted drives.
Don't check with QFileInfo::isWritable if it is writable, if not yet known, return true.
Don't check with QFileInfo::isReadable if it is readable, return false.
Don't check for desktop files just return false.
Ignore .hidden files on slow paths.
Don't read mime comment from .desktop or .directory files.
Don't get the size with QFileInfo::size, just return 0, if not yet known.
Don't determine mime type from file content, use file extension.
Don't check for desktop files just return false.
Don't call KFileSystemType::fileSystemType to check if the filesystem is slow, just return true.
Don't count files/directories in subdirectories.
Don't calculate sizes of subdirectories.
Avoid check for dir at Kate startup

MediumSideEffectsOptimizations 

Don't return project for dir, avoid QFileInfo().absoluteDir()
Don't search for .kateconfig recursively
Ignore recent files on slow paths.

StrongSideEffectsOptimizations 

Turn off symbolic link resolution.

KDirWatchDontAddWatches 

Disables dir watching completely for slow paths, avoids stat() calls on added dirs and subdirs.

SymlinkPathsUseCache 

Cache resolved symlink paths.

Definition at line 75 of file knetworkmounts.h.

◆ KNetworkMountsType

The KNetworkMountsType enum.

Enumerator
NfsPaths 

NFS paths.

SmbPaths 

SMB paths.

SymlinkDirectory 

Paths to directories which contain symbolic links to network mounts.

SymlinkToNetworkMount 

Paths which are symbolic links to network mounts.

Any 

Any slow path type. Do not use with setPaths or addPath.

Definition at line 102 of file knetworkmounts.h.

Member Function Documentation

◆ addPath()

void KNetworkMounts::addPath ( const QString & path,
KNetworkMountsType type )

Add a path for which optimizations are to take place.

Parameters
paththe path to add
typethe type of the path. Do not use Any
See also
KNetworkMountsType

Definition at line 109 of file knetworkmounts.cpp.

◆ canonicalSymlinkPath()

QString KNetworkMounts::canonicalSymlinkPath ( const QString & path)

Resolves a path that may contain symbolic links to mounted network shares.

A symlink path is either a directory which contains symbolic links to slow network mounts (SymlinkDirectory) or a direct symbolic link to a slow network mount (SymlinkToNfsOrSmbPaths).

Example: There are some Samba shares mounted below /mnt. These are paths of type SmbPaths

/mnt/server1/share1
/mnt/server1/share2
/mnt/server2/share3

A (logged in) user may have symbolic links to them in his home directory below netshares. The directory /home/user/netshares is a SymlinkDirectory:

/home/user/netshares/share1 -> /mnt/server1/share1
/home/user/netshares/share2 -> /mnt/server1/share2
/home/user/netshares/share3 -> /mnt/server2/share3

There is a direct symbolic link from /home/user/share1 to /mnt/server1/share1. This is of type SymlinkToNfsOrSmbPaths:

/home/user/share1 -> /mnt/server1/share1

Both types of symbolic links from symlink paths to the real mounted shares are resolved even if KNetworkMountOption StrongSideEffectsOptimizations is enabled.

If the setup is like above a path

/home/user/netshares/share1/Documents/file.txt

would be resolved to

/mnt/server1/share1/Documents/file.txt

and a path

/home/user/share1/Documents/file.txt

would also be resolved to

/mnt/server1/share1/Documents/file.txt

Resolved paths are cached in a hash.

Parameters
paththe path to resolve
Returns
the resolved path or path if path is not a symlink path or no symlink found
See also
KNetworkMountsType
clearCache
isSlowPath

Definition at line 121 of file knetworkmounts.cpp.

◆ clearCache()

void KNetworkMounts::clearCache ( )

Clears the canonical symlink path cache.

Call this if directory structures on mounted network drives changed. Don't enable the cache (SymlinkPathsUseCache) if this happens often and the drives are usually accessed via the symlinks. This method exists mainly for the KCM.

See also
canonicalSymlinkPath

Definition at line 207 of file knetworkmounts.cpp.

◆ isEnabled()

bool KNetworkMounts::isEnabled ( ) const

Query if the performance optimizations are switched on.

Returns
true if on, false otherwise

Definition at line 67 of file knetworkmounts.cpp.

◆ isOptionEnabled()

bool KNetworkMounts::isOptionEnabled ( const KNetworkMountOption option,
const bool defaultValue = false ) const

Query a performance option.

Parameters
optionthe option to query
defaultValuethe value to return if the option is not configured
Returns
true if option is on, false if not
See also
KNetworkMountOption

Definition at line 77 of file knetworkmounts.cpp.

◆ isOptionEnabledForPath()

bool KNetworkMounts::isOptionEnabledForPath ( const QString & path,
KNetworkMountOption option )

Query if path is configured to be a slow path and option is enabled.

Parameters
paththe path to query
optionthe option to query
Returns
true if path is a configured slow path and option option is enabled

Definition at line 54 of file knetworkmounts.cpp.

◆ isSlowPath()

bool KNetworkMounts::isSlowPath ( const QString & path,
KNetworkMountsType type = Any )

Query if path is configured to be a slow path of type type.

Parameters
paththe path to query
typethe type to query. If omitted, any type matches
Returns
true if path is a configured slow path of type type

This function is also used to determine the filesystem type in KFileSystemType::fileSystemType (KFileSystemType::Smb or KFileSystemType::Nfs) without an expensive call to stafs(). For this to work the types of paths need to be correctly assigned in setPath or addPath

Definition at line 49 of file knetworkmounts.cpp.

◆ paths()

QStringList KNetworkMounts::paths ( KNetworkMountsType type = Any) const

Query the configured paths for which optimizations are to take place.

Returns
a list of paths

Definition at line 87 of file knetworkmounts.cpp.

◆ self()

KNetworkMounts * KNetworkMounts::self ( )
static

Returns (and creates if necessary) the singleton instance.

Returns
the singleton instance

Definition at line 23 of file knetworkmounts.cpp.

◆ setEnabled()

void KNetworkMounts::setEnabled ( bool value)

Switch the performance optimizations on or off.

Parameters
valuethe value to set

Definition at line 72 of file knetworkmounts.cpp.

◆ setOption()

void KNetworkMounts::setOption ( const KNetworkMountOption option,
const bool value )

Switch a performance option on or off.

Parameters
optionthe option to change
valuethe value to set
See also
KNetworkMountOption

Definition at line 82 of file knetworkmounts.cpp.

◆ setPaths()

void KNetworkMounts::setPaths ( const QStringList & paths,
KNetworkMountsType type )

Set the paths for which optimizations are to take place.

Parameters
pathsthe paths to set
typethe type of paths. Do not use Any
See also
KNetworkMountsType

Definition at line 102 of file knetworkmounts.cpp.

◆ sync()

void KNetworkMounts::sync ( )

Synchronizes to config file.

QSettings synchronization also takes place automatically at regular intervals and from QSettings destructor, see QSettings::sync() documentation.

Calls QSettings::sync()

Definition at line 214 of file knetworkmounts.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.