kget
#include <urlchecker.h>
Public Types | |
enum | UrlError { NoError = 0, Empty, Invalid, NoProtocol, NoHost, NotWriteable } |
enum | UrlType { Source, Destination, Folder } |
enum | UrlWarning { NoWarning = 0, ExistingFinishedTransfer, ExistingTransfer, ExistingFile } |
Public Member Functions | |
UrlChecker (UrlType type) | |
~UrlChecker () | |
UrlError | addUrl (const KUrl &url) |
bool | addUrls (const KUrl::List &urls) |
KUrl | checkExistingFile (const KUrl &source, const KUrl &destination) |
void | clear () |
KUrl::List | correctUrls () const |
void | displayErrorMessages () |
KUrl::List | errorUrls () const |
void | existingTransfers () |
void | setType (UrlType type) |
QHash< UrlError, KUrl::List > | splitErrorUrls () const |
UrlType | type () const |
Static Public Member Functions | |
static UrlError | checkDestination (const KUrl &destination, bool showNotification=false) |
static UrlError | checkFolder (const KUrl &folder, bool showNotification=false) |
static UrlError | checkSource (const KUrl &source, bool showNotification=false) |
static UrlError | checkUrl (const KUrl &url, const UrlType type, bool showNotification=false) |
static KUrl | destUrl (const KUrl &destOrFolder, const KUrl &source, const QString &fileName=QString()) |
static TransferHandler * | existingTransfer (const KUrl &url, const UrlType type, UrlWarning *warning=0) |
static KUrl::List | hasExistingTransferMessages (const KUrl::List &urls, const UrlType type) |
static QString | message (const KUrl &url, const UrlType type, const UrlError error) |
static QString | message (const KUrl &url, const UrlType type, const UrlWarning warning) |
static QString | message (const KUrl::List &urls, const UrlType type, const UrlError error) |
static QString | message (const KUrl::List &urls, const UrlType type, const UrlWarning warning) |
static void | removeDuplicates (KUrl::List &urls) |
static bool | wouldOverwrite (const KUrl &source, const KUrl &dest) |
Detailed Description
This class provides static methods to check if urls are valid, and if not provides enums to see what is not valid and provides translated error messages.
Definition at line 34 of file urlchecker.h.
Member Enumeration Documentation
enum UrlChecker::UrlError |
Enumerator | |
---|---|
NoError | |
Empty | |
Invalid | |
NoProtocol | |
NoHost | |
NotWriteable |
Definition at line 59 of file urlchecker.h.
enum UrlChecker::UrlType |
Enumerator | |
---|---|
Source | |
Destination | |
Folder |
Definition at line 37 of file urlchecker.h.
Enumerator | |
---|---|
NoWarning | |
ExistingFinishedTransfer | |
ExistingTransfer | |
ExistingFile |
Definition at line 73 of file urlchecker.h.
Constructor & Destructor Documentation
|
explicit |
Before using UrlChecker you have to specify a type You can either do that in the constructor and later via setType.
- See also
- setType
Definition at line 90 of file urlchecker.cpp.
UrlChecker::~UrlChecker | ( | ) |
Definition at line 99 of file urlchecker.cpp.
Member Function Documentation
UrlChecker::UrlError UrlChecker::addUrl | ( | const KUrl & | url | ) |
Checks url of type()
- Returns
- UrlError, None if no error has been found
- Note
- checkExisting is not done within this method
- both this method and checkUrls() will store all correct urls in correctUrls() and the others in errorUrls() and splitErrorUrls()
Definition at line 697 of file urlchecker.cpp.
bool UrlChecker::addUrls | ( | const KUrl::List & | urls | ) |
Does checkUrl for a list of urls.
- Returns
- true if all urls are valid, false, if at least one url is invalid
- Note
- checkExisting is not done within this method
- both this method and checkUrl() will store all correct urls in correctUrls() and the others in errorUrls() and splitErrorUrls()
- See also
- addUrl
Definition at line 709 of file urlchecker.cpp.
|
static |
Convenience method of checkUrl.
- Parameters
-
showNotification true shows a notification if an error is found
Definition at line 166 of file urlchecker.cpp.
KUrl UrlChecker::checkExistingFile | ( | const KUrl & | source, |
const KUrl & | destination | ||
) |
Checks if the file at destination exists already, source needs to be defined to have a nice dialog and to make sure that both source and destination aren't the same.
- Note
- This method does not affect other methods like correctUrls or existingTransfers etc., though responses like overwrite all files are stored in case you call this method again you can clear that with clear.
- Returns
- returns the destination to download the file to, if empty then the file should not be downloaded
- See also
- clear
in the following cases no dialog needs to be shown
now show the dialog and look at the result
Definition at line 727 of file urlchecker.cpp.
|
static |
Convenience method of checkUrl.
- Parameters
-
showNotification true shows a notification if an error is found
Definition at line 195 of file urlchecker.cpp.
|
static |
Convenience method of checkUrl.
- Parameters
-
showNotification true shows a notification if an error is found
Definition at line 139 of file urlchecker.cpp.
|
static |
Folder: Checks if the destination url points to is a folder that is writeable and existent.
Destination: Checks if url points to a file (can be non-existent) and if the directory this file is (would) be in is existent and writeable
- Parameters
-
type all types supported here showNotification true shows a notification if an error is found
- Note
- checkExisting is not done within this method
- you can use the convenience methods checkSource, checkDestination, checkFolder directly
- See also
- checkExisting
Definition at line 120 of file urlchecker.cpp.
void UrlChecker::clear | ( | ) |
Clears all data, like correctUrls, errorUrls, responses from checkExistingFile ...
Non static methods following.
Definition at line 676 of file urlchecker.cpp.
KUrl::List UrlChecker::correctUrls | ( | ) | const |
Returns the correct urls collected with the last call to urlCollectErrors.
- See also
- urlCollectErrors
Definition at line 797 of file urlchecker.cpp.
|
static |
Takes an url to a source and an url to either the destination or a folder and returns a destination url.
- Parameters
-
destOrFolder *is an existing folder then a file name derived from source will be appended to it and returned *otherwise no modification will be done and destOrFolder will be returned
- Note
- no checkUrl check happens!
- See also
- checkUrl
Definition at line 225 of file urlchecker.cpp.
void UrlChecker::displayErrorMessages | ( | ) |
Displays error messages for the collected urls if any are needed.
Definition at line 820 of file urlchecker.cpp.
KUrl::List UrlChecker::errorUrls | ( | ) | const |
Returns all wrong urls.
- Note
- the oder of the urls is not guaranteed to be the same as it initially was
- See also
- urlCollectErrors splitErrorUrls existingTransfers
Definition at line 802 of file urlchecker.cpp.
|
static |
Checks if there is an existing transfer for url with type.
- Parameters
-
type *Source checks if there is a transfer with the same source *Destination checks if there is a transfer with the same destination
- Returns
- if an existing transfer is found it will be returned, otherwise 0 will be returned
- Note
- checkUrl check is not done and UrlType Folder is not supported Keep in mind, that the same transfers could be found via Source and Destination!
- See also
- checkUrl
Definition at line 242 of file urlchecker.cpp.
void UrlChecker::existingTransfers | ( | ) |
Checks all correctUrls() if there are existing Transfers for the specified UrlType and asks the user how to proceed.
After this urls where the user decided that they should not be downloaded won't be in correctUrls anymore.
- Note
- UrlType folder is not supported, the result then is undefined!
- Returns
- urls to download, after user interaction
- See also
- correctUrls errorUrls splitErrorUrls
Definition at line 722 of file urlchecker.cpp.
|
static |
- Note
- UrlType folder is not supported, the result then is undefined!
Definition at line 544 of file urlchecker.cpp.
Get a describing message for UrlError.
- Parameters
-
url is only needed here to include it in some error messages, if url is empty, then it won't be used.
- Note
- this method does no checks, it only creates messages based on the error code
- See also
- checkUrl
Definition at line 290 of file urlchecker.cpp.
|
static |
Get a describing message for UrlWarning.
- Parameters
-
url is only needed here to include it in some error messages, if url is empty, then it won't be used.
- Note
- this method does no checks, it only creates messages based on the warning code
- See also
- existingTransfer fileExists
Definition at line 376 of file urlchecker.cpp.
|
static |
Convenience method for multiple urls (urls can be empty)
- See also
- message
Definition at line 432 of file urlchecker.cpp.
|
static |
Convenience method for multiple urls (urls can be empty)
- See also
- message
Definition at line 481 of file urlchecker.cpp.
|
static |
Removes duplicates of a list of urls.
Definition at line 113 of file urlchecker.cpp.
void UrlChecker::setType | ( | UrlChecker::UrlType | type | ) |
Sets the type for the following operations to type.
- Note
- calls clear
- See also
- clear
Definition at line 691 of file urlchecker.cpp.
QHash< UrlChecker::UrlError, KUrl::List > UrlChecker::splitErrorUrls | ( | ) | const |
Returns all wrong urls collected with the last call to urlCollectErrors or existingTransfers categorized by their errors.
- Note
- urls without an error (UrlError == None) are not included
- See also
- urlCollectErrors correctUrls errorUrls existingTransfers
Definition at line 815 of file urlchecker.cpp.
UrlChecker::UrlType UrlChecker::type | ( | ) | const |
Non static methods following.
Definition at line 686 of file urlchecker.cpp.
|
static |
Checks if source is local and exists already.
- Note
- If both dest and source are the same and local, then false will be returned since it is assumed, that local files are either not handled by any transfer plugin or are e.g. metalink or torrent files otherwise and thus can have the same source/dest. Also keep in mind that false will be returned if dest is being removed at the moment. Avoid to ask a user twice in worst case.
Definition at line 134 of file urlchecker.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.