UpdateOperation Class
class KDUpdater::UpdateOperationThe UpdateOperation class is an abstract base class for update operations. More...
Header: | #include <UpdateOperation> |
Public Types
flags | OperationGroups |
Public Functions
QString | argumentKeyValue(const QString &key, const QString &defaultValue = QString()) const |
QStringList | arguments() const |
virtual void | backup() = 0 |
void | clear() |
void | clearValue(const QString &name) |
int | error() const |
QString | errorString() const |
QStringList | filesForDelayedDeletion() const |
virtual bool | fromXml(const QDomDocument &doc) |
virtual bool | fromXml(const QString &xml) |
KDUpdater::UpdateOperation::OperationGroup | group() const |
bool | hasValue(const QString &name) const |
QString | name() const |
QString | operationCommand() const |
QInstaller::PackageManagerCore * | packageManager() const |
virtual bool | performOperation() = 0 |
bool | requiresUnreplacedVariables() const |
void | setArguments(const QStringList &args) |
void | setValue(const QString &name, const QVariant &value) |
virtual quint64 | sizeHint() |
virtual bool | testOperation() = 0 |
virtual QDomDocument | toXml() const |
virtual bool | undoOperation() = 0 |
QVariant | value(const QString &name) const |
Protected Functions
bool | checkArgumentCount(int argCount) |
bool | checkArgumentCount(int minArgCount, int maxArgCount, const QString &argDescription = QString()) |
bool | deleteFileNowOrLater(const QString &file, QString *errorString = 0) |
QStringList | parsePerformOperationArguments() |
void | registerForDelayedDeletion(const QStringList &files) |
void | setError(int error, const QString &errorString = QString()) |
void | setErrorString(const QString &str) |
void | setGroup(const KDUpdater::UpdateOperation::OperationGroup &group) |
void | setName(const QString &name) |
void | setRequiresUnreplacedVariables(bool isRequired) |
bool | skipUndoOperation() |
bool | variableReplacement(QString *variableValue) |
Detailed Description
The KDUpdater::UpdateOperation is an abstract class that specifies an interface for update operations. Concrete implementations of this class must perform a single update operation, such as copy, move, or delete.
Note: Two separate threads cannot be using a single instance of KDUpdater::UpdateOperation at the same time.
Member Function Documentation
QString UpdateOperation::argumentKeyValue(const QString &key, const QString &defaultValue = QString()) const
Searches the arguments for the key specified by key. If it can find the key, it returns the value set for it. Otherwise, it returns defaultValue. Arguments are specified in the following form: key=value
.
QStringList UpdateOperation::arguments() const
Returns the arguments of the update operation.
See also setArguments().
[pure virtual]
void UpdateOperation::backup()
Subclasses must implement this function to back up any data before performing the action.
[protected]
bool UpdateOperation::checkArgumentCount(int argCount)
Returns true
if the argument count is exactly argCount.
[protected]
bool UpdateOperation::checkArgumentCount(int minArgCount, int maxArgCount, const QString &argDescription = QString())
Returns true
if the argument count is within limits of minArgCount and maxArgCount. argDescription contains information about the expected form.
void UpdateOperation::clear()
Clears the previously set arguments.
void UpdateOperation::clearValue(const QString &name)
Clears the value of name and removes it.
[protected]
bool UpdateOperation::deleteFileNowOrLater(const QString &file, QString *errorString = 0)
Tries to delete file. If file cannot be deleted, it is registered for delayed deletion.
If a backup copy of the file cannot be created, returns false
and displays the error message specified by errorString.
int UpdateOperation::error() const
Returns the error that was found during the processing of the operation. If no error was found, returns NoError. Subclasses can set more detailed error codes (optional).
Note: To check if an operation was successful, use the return value of performOperation(), undoOperation(), or testOperation().
See also setError().
QString UpdateOperation::errorString() const
Returns a human-readable description of the last error that occurred.
See also setErrorString().
QStringList UpdateOperation::filesForDelayedDeletion() const
Returns the list of files that are scheduled for later deletion.
[virtual]
bool UpdateOperation::fromXml(const QDomDocument &doc)
Restores operation arguments and values from the XML document doc. Returns true
on success, otherwise false
.
Note: : Clears all previously set values and arguments.
[virtual]
bool UpdateOperation::fromXml(const QString &xml)
This is an overloaded function.
Restores operation arguments and values from the XML file at path xml. Returns true
on success, otherwise false
.
KDUpdater::UpdateOperation::OperationGroup UpdateOperation::group() const
Returns the execution group this operation belongs to.
See also setGroup().
bool UpdateOperation::hasValue(const QString &name) const
Returns true
if a value called name exists, otherwise returns false
.
QString UpdateOperation::name() const
Returns the update operation name.
See also setName().
QString UpdateOperation::operationCommand() const
Returns a command line string that describes the update operation. The returned string will be of the form:
<name> <arg1> <arg2> <arg3> ....
QInstaller::PackageManagerCore *UpdateOperation::packageManager() const
Returns the package manager core this operation belongs to.
[protected]
QStringList UpdateOperation::parsePerformOperationArguments()
Returns operation argument list without UNDOOOPERATION
arguments.
[pure virtual]
bool UpdateOperation::performOperation()
Subclasses must implement this function to perform the update operation.
Returns true
if the operation is successful.
[protected]
void UpdateOperation::registerForDelayedDeletion(const QStringList &files)
Registers a list of files to be deleted later once the application was restarted and the file or files are not used anymore.
bool UpdateOperation::requiresUnreplacedVariables() const
Returns true if installer saves the variables unresolved. The variables are resolved right before operation is performed.
See also setRequiresUnreplacedVariables().
void UpdateOperation::setArguments(const QStringList &args)
Sets the arguments for the update operation to args.
See also arguments().
[protected]
void UpdateOperation::setError(int error, const QString &errorString = QString())
Sets the error condition to be error. The human-readable message is set to errorString.
See also UpdateOperation::error() and UpdateOperation::errorString().
[protected]
void UpdateOperation::setErrorString(const QString &str)
Sets the human-readable description of the last error that occurred to str.
See also errorString().
[protected]
void UpdateOperation::setGroup(const KDUpdater::UpdateOperation::OperationGroup &group)
Sets the execution group of the operation to group. Subclasses can change the group to control which installation phase this operation should be run in.
The default group is Install
.
See also group().
[protected]
void UpdateOperation::setName(const QString &name)
Sets the name of the operation to name. Subclasses will have to provide a unique name to describe the operation.
See also name().
[protected]
void UpdateOperation::setRequiresUnreplacedVariables(bool isRequired)
Sets the requirement for unresolved variables to isRequired.
See also requiresUnreplacedVariables().
void UpdateOperation::setValue(const QString &name, const QVariant &value)
Sets the value of name to value.
See also value().
[virtual]
quint64 UpdateOperation::sizeHint()
Returns a numerical representation of how this operation compares to other operations in size, and in time it takes to perform the operation.
The default returned value is 1
. Subclasses may override this method to implement custom size hints.
[protected]
bool UpdateOperation::skipUndoOperation()
Returns true
if operation undo should not be performed. Returns false
if the installation is cancelled or failed, or UNDOOPERATION
is not set in operation call.
[pure virtual]
bool UpdateOperation::testOperation()
Subclasses must implement this function to perform the test operation.
Returns true
if the operation is successful.
[virtual]
QDomDocument UpdateOperation::toXml() const
Saves operation arguments and values as an XML document and returns the document. You can override this method to store your own extra-data. Extra-data can be any data that you need to store to perform or undo the operation. The default implementation is taking care of arguments and values set via UpdateOperation::setValue().
[pure virtual]
bool UpdateOperation::undoOperation()
Subclasses must implement this function to perform the undo of the update operation.
Returns true
if the operation is successful.
QVariant UpdateOperation::value(const QString &name) const
Returns the value of name. If the value does not exist, returns an empty QVariant.
See also setValue().
[protected]
bool UpdateOperation::variableReplacement(QString *variableValue)
Replaces installer value
variableValue with predefined variable. If key
is found for the variableValue and the key
ends with string _OLD, the initial variableValue is replaced with the value
having a key without _OLD ending. This way we can replace the hard coded values defined for operations, if the value has for some reason changed. For example if we set following variables in install script:
installer.setValue("MY_OWN_EXECUTABLE", "C:/Qt/NewLocation/Tools.exe") installer.setValue("MY_OWN_EXECUTABLE_OLD", "C:/Qt/OldLocation/Tools.exe")
and we have moved the Tools.exe from OldLocation to NewLocation, the operation continues to work and use the Tools.exe from NewLocation although original installation has been made with Tools.exe in OldLocation. Returns true
if variableValue is replaced.
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. The Qt Company, Qt and their respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.