Scrape the Web for Doom WADs and install them. More...
#include <wadseeker.h>
Public Slots | |
void | abort () |
Tell Wadseeker to stop the seek session. | |
Signals | |
void | allDone (bool bSuccess) |
Emitted when Wadseeker finishes iterating through all files passed to startSeek(). | |
void | fileDownloadFinished (const ModFile &filename) |
Emitted when a particular file finishes downloading. | |
void | fileDownloadProgress (const ModFile &filename, qint64 done, qint64 total) |
Emits download progress. | |
void | fileDownloadStarted (const ModFile &filename, const QUrl &url) |
Emitted when a file download starts. | |
void | fileInstalled (const ModFile &filename) |
Emitted when a particular file is installed correctly. | |
void | message (const QString &msg, WadseekerLib::MessageType type) |
Emits Wadseeker's log messages. | |
void | seekStarted (const ModSet &filenames) |
Emitted when Wadseeker begins the seek operation, upon a successful startSeek(). | |
void | serviceFinished (const QString &name) |
Notifies that Wadseeker is done querying a named service. | |
void | serviceStarted (const QString &name) |
Notifies that Wadseeker started querying a named service. | |
void | siteFinished (const QUrl &site) |
Emitted when a WWW site finishes downloading. | |
void | siteProgress (const QUrl &site, qint64 bytes, qint64 total) |
Emits download progress of a WWW site. | |
void | siteRedirect (const QUrl &oldUrl, const QUrl &newUrl) |
Emitted when a WWW site redirects to a different site. | |
void | siteStarted (const QUrl &site) |
Emitted when a download of a WWW site starts. | |
Public Member Functions | |
Wadseeker () | |
Initializes a new instance of Wadseeker. | |
~Wadseeker () override | |
Deallocates an instance of Wadseeker. | |
bool | isDownloadingFile (const ModFile &file) const |
Check if Wadseeker is currently downloading given file. | |
bool | isWorking () const |
Check if Wadseeker is still working. | |
void | setCustomSite (const QString &url) |
Set a high-priority URL to scrape for WADs. | |
void | setCustomSites (const QStringList &urls) |
setCustomSite(), but more than one. | |
void | setIdgamesEnabled (bool bEnabled) |
Set the /idgames Archive enabled. | |
void | setIdgamesUrl (QString archiveURL) |
Set the URL to the /idgames Archive search page. | |
void | setMaximumConcurrentDownloads (unsigned max) |
Set maximum number of concurrent WAD downloads. | |
void | setMaximumConcurrentSeeks (unsigned max) |
Set maximum number of concurrent site seeks (scrapings). | |
void | setPrimarySites (const QStringList &urlList) |
Set a list of primary sites to scrape for WADs. | |
void | setPrimarySitesToDefault () |
Reset the list of primary sites to the sites hardcoded into Wadseeker. | |
void | setTargetDirectory (const QString &dir) |
Set the WAD installation target directory. | |
void | setWadArchiveEnabled (bool enabled) |
Does nothing, because Wad Archive is defunct. | |
void | skipFileCurrentUrl (const QString &fileName) |
Abort the current URL for the specified file. | |
void | skipService (const QString &service) |
Abort querying a named service if such query is in progress. | |
void | skipSiteSeek (const QUrl &url) |
Abort scraping the site at the specified URL. | |
bool | startSeek (const ModSet &wads) |
Launch the WAD retrieval session. | |
QString | targetDirectory () const |
Target directory is a directory where all seeked files will be saved. | |
Static Public Member Functions | |
static const QString | defaultIdgamesUrl () |
Default URL to the /idgames Archive. | |
static QStringList | defaultSitesListEncoded () |
Percent-encoded Wadseeker::defaultSites. | |
static ModSet | filterAllowedOnlyWads (const ModSet &wads) |
List only WADs for which isForbiddenWad() returns false. | |
static ModSet | filterForbiddenOnlyWads (const ModSet &wads) |
List only WADs for which isForbiddenWad() returns true. | |
static bool | isForbiddenWad (const ModFile &wad) |
Check if the file is on the list of forbidden WADs. | |
Static Public Attributes | |
static const QString | defaultSites [] |
Default sites to scrape for files. | |
static const QString | forbiddenWads [] |
Files that are not meant to be freely downloadable. | |
Scrape the Web for Doom WADs and install them.
The Wadseeker class provides an interface for searching for and downloading modifications for Doom (1993) engine games. Create its object, set it up with various setters methods, and then launch it with startSeek().
All setup must be done before startSeek() is called. Wadseeker will ignore any setup changes aftewards.
Wadseeker will search for mods in a list of locations provided to setPrimarySites() and setCustomSites(). It can also contact the /idgames Archive, which can be toggled with setIdgamesEnabled().
Wadseeker will ignore a predefined set of file names which it suspects to be attempts to illegally download commercial game data, so passing in any name for which isForbiddenWad() returns true
will result in the file being ignored.
It's not advisable, even if technically allowed, to have more than one instance of this class running simultaneously. Some Web servers limit the amount of simultaneous connections per client, and Wadseeker organizes its scraping with that mind, but it can only do that within a single seek session. It can't synchronize between multiple instances of itself.
Definition at line 183 of file wadseeker.h.
Wadseeker::Wadseeker | ( | ) |
Initializes a new instance of Wadseeker.
|
override |
Deallocates an instance of Wadseeker.
|
slot |
|
signal |
Emitted when Wadseeker finishes iterating through all files passed to startSeek().
bSuccess | True if all seeked WADs were installed. False if any single one of the WADs was not found or if abort was issued. |
|
static |
Default URL to the /idgames Archive.
|
static |
Percent-encoded Wadseeker::defaultSites.
Runs content of defaultSites array through QUrl::toPercentEncoding() and returns a list of so encoded strings.
|
signal |
Emitted when a particular file finishes downloading.
NOTE: This doesn't mean that the WAD was successfully installed. It only serves as a notification that a download has been completed.
filename | Unique filename for the affected file. Emitted previously by seekStarted() signal as an entry on the filenames list. |
|
signal |
Emits download progress.
The progress values may be used to update a progress bar.
filename | Unique filename for the affected file. Emitted previously by seekStarted() signal as an entry on the filenames list. |
done | Bytes already downloaded. |
total | Total size of the downloaded file. |
|
signal |
Emitted when a file download starts.
filename | Name of the downloaded file. |
url | URL from which the file is being downloaded. |
|
signal |
Emitted when a particular file is installed correctly.
filename | Unique filename for the affected file. Emitted previously by seekStarted() signal as an entry on the filenames list. |
|
static |
List only WADs for which isForbiddenWad() returns false.
|
static |
List only WADs for which isForbiddenWad() returns true.
bool Wadseeker::isDownloadingFile | ( | const ModFile & | file | ) | const |
Check if Wadseeker is currently downloading given file.
file | Name of the file as specified by seekStarted() signal. |
|
static |
Check if the file is on the list of forbidden WADs.
wad | WAD to check. |
bool Wadseeker::isWorking | ( | ) | const |
Check if Wadseeker is still working.
|
signal |
Emits Wadseeker's log messages.
msg | Text of the message. |
type | Log severity level. |
|
signal |
Emitted when Wadseeker begins the seek operation, upon a successful startSeek().
filenames | Contains unique names of all files that will be seeked. Wadseeker will continue to refer to those filenames in other signals. |
|
signal |
Notifies that Wadseeker is done querying a named service.
name | Unique name of the service. |
|
signal |
Notifies that Wadseeker started querying a named service.
Currently there is only one such service: idgames
.
name | Unique name of the service. Can be used to abort querying of this service by passing it to skipService(). |
void Wadseeker::setCustomSite | ( | const QString & | url | ) |
Set a high-priority URL to scrape for WADs.
This site has priority over all other sites and will be searched first. A direct URL to the file can also be used.
This is a good place to pass in the link provided by the game server.
url | A valid, absolute URL. |
void Wadseeker::setCustomSites | ( | const QStringList & | urls | ) |
setCustomSite(), but more than one.
Because this is a "set", it overwrites any previous custom sites, including the one set by setCustomSite().
urls | A list of valid, absolute URLs. |
void Wadseeker::setIdgamesEnabled | ( | bool | bEnabled | ) |
Set the /idgames Archive enabled.
If true, /idgames Archive search will be performed. If false, the /idgames Archive will be skipped.
The /idgames Archive is enabled by default.
void Wadseeker::setIdgamesUrl | ( | QString | archiveURL | ) |
Set the URL to the /idgames Archive search page.
Wadseeker already hardcodes the URL to the /idgames Archive and uses it by default, so in normal operation there should be no need to use this method.
void Wadseeker::setMaximumConcurrentDownloads | ( | unsigned | max | ) |
Set maximum number of concurrent WAD downloads.
Default value: 3.
max | Number of max. concurrent downloads. Cannot be lesser than 1. |
void Wadseeker::setMaximumConcurrentSeeks | ( | unsigned | max | ) |
Set maximum number of concurrent site seeks (scrapings).
Default value: 3.
max | Number of max. concurrent seeks. Cannot be less than 1. |
void Wadseeker::setPrimarySites | ( | const QStringList & | urlList | ) |
Set a list of primary sites to scrape for WADs.
This is where Wadseeker begins its search.
urlList | List of valid, absolute URLs. |
void Wadseeker::setPrimarySitesToDefault | ( | ) |
Reset the list of primary sites to the sites hardcoded into Wadseeker.
Calling this is normally not needed, because Wadseeker already initializes the primary sites to this default list. However, if you changed the list and want to go back to the default one, this is the way to do it.
void Wadseeker::setTargetDirectory | ( | const QString & | dir | ) |
Set the WAD installation target directory.
The target directory is the directory where all the seeked files will be saved to. If this directory is not writable, the seek will fail.
dir | Path to a writable directory. |
void Wadseeker::setWadArchiveEnabled | ( | bool | enabled | ) |
Does nothing, because Wad Archive is defunct.
If set to true, Wadseeker would contact Wad Archive to look for WAD URLs, but the site is dead.
Wad Archive: http://www.wad-archive.com
|
signal |
Emitted when a WWW site finishes downloading.
|
signal |
Emits download progress of a WWW site.
|
signal |
Emitted when a WWW site redirects to a different site.
|
signal |
Emitted when a download of a WWW site starts.
void Wadseeker::skipFileCurrentUrl | ( | const QString & | fileName | ) |
Abort the current URL for the specified file.
The current download will be aborted, but a new file URL will be immediately taken from the queue if available, and a new download will begin for this file.
This method gives the user the option to abort the current download for this file if the site is slow.
fileName | This must be a file name as previously sent by seekStarted() signal. If the file name is not valid or download for this file is not in progress, then no operation will be performed. |
void Wadseeker::skipService | ( | const QString & | service | ) |
Abort querying a named service if such query is in progress.
The name of the service is previously emitted by serviceStarted() signal.
service | Name of the service as emitted by serviceStarted() signal. |
void Wadseeker::skipSiteSeek | ( | const QUrl & | url | ) |
Abort scraping the site at the specified URL.
Wadseeker will immediately start scraping the next site in the queue.
url | This must be one of the URLs that was emitted through siteStarted() or siteRedirect() signals. If an unknown URL is passed, no operation will be performed. |
bool Wadseeker::startSeek | ( | const ModSet & | wads | ) |
Launch the WAD retrieval session.
Setup the seek first using other methods, then call this method to start it. This is where Wadseeker begins to iterate through WWW sites to find all the desired files.
One of the three things may happen after here:
true
.false
result, but true
is still returned from here.false
is returned and no signals are emitted.The list of files emitted in seekStarted() may be different than the list of files passed to startSeek() in case of duplicates or if any of the files was on the isForbiddenWad() list.
wads | List of files that will be searched for. |
QString Wadseeker::targetDirectory | ( | ) | const |
Target directory is a directory where all seeked files will be saved.
If setTargetDirectory() is called after a seek session is started with startSeek(), this method will return the newly set directory, not the one from the running session.
|
static |
Default sites to scrape for files.
Definition at line 193 of file wadseeker.h.
|
static |
Files that are not meant to be freely downloadable.
List of file names that will be ignored as they are part of a commercial product. Empty string at the end of the array is required and indicates the end of the array.
Definition at line 204 of file wadseeker.h.