Difference between revisions of "CampaignServerWML"

From The Battle for Wesnoth Wiki
(Response)
m (minor wikification)
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
<div class="tright"> __TOC__ </div>
 
<div class="tright"> __TOC__ </div>
  
This page describes the WML commands exchanged between the add-ons server (<b>campaignd</b>) and clients.
+
This page describes the WML commands exchanged between the add-ons server (<b>[[campaignd]]</b>) and clients.
  
 
For historical reasons, both the server software's name and the WML tags which are part of its communication protocol make exclusive reference to "campaigns" instead of "add-ons". However, in practice there is no real difference between any kind of add-ons as far as the server is concerned.
 
For historical reasons, both the server software's name and the WML tags which are part of its communication protocol make exclusive reference to "campaigns" instead of "add-ons". However, in practice there is no real difference between any kind of add-ons as far as the server is concerned.
Line 23: Line 23:
 
** '''message''': String containing an error message for the client to display to the user.
 
** '''message''': String containing an error message for the client to display to the user.
 
** '''extra_data''': String containing additional information for the client to display. This is often a log of some kind (such a list of illegal filenames found during an upload request), so a client should be prepared for this to be an overlong string that might not completely fit in the screen.
 
** '''extra_data''': String containing additional information for the client to display. This is often a log of some kind (such a list of illegal filenames found during an upload request), so a client should be prepared for this to be an overlong string that might not completely fit in the screen.
 +
 +
== Archive format ==
 +
 +
'''[upload]''' and '''[request_campaign]''' both use WML to describe archives containing the directory structure and files for each add-on. The archive format supports only regular files and directories, and file contents need to be encoded in a special fashion so that they can be serialized as WML for network transfers and disk storage.
 +
 +
Binary data cannot contain null characters, as well as certain special characters. In order to build escape sequences for them, a single-byte value of <code>0x01</code> is used followed by the actual byte value incremented by 1. For example, the byte sequence <code>0x01 0x01</code> is used to represent the null character <code>0x00</code>, and <code>0x01 0xFF</code> represents the special character <code>0xFE</code>.
 +
 +
As of Wesnoth 1.14, the following byte values need to be escaped:
 +
 +
<code>0x00</code> (null character), <code>0x01</code> (escape character), <code>0x0D</code> (carriage return), <code>0xFE</code> (used by the WML parser to encode <code>\xFEline</code> and <code>\xFEtextdomain</code> directives).
 +
 +
=== [file]: Regular file ===
 +
 +
* '''name''': Filename (not a relative or absolute path).
 +
* '''contents''': The contents of a file encoded as binary data as described above.
 +
 +
=== [dir]: Directory ===
 +
 +
* '''name''': Directory name (not a relative or absolute path).
 +
* '''[file]''', '''[dir]''': Regular files and subdirectories under this directory. The syntax for '''[dir]''' is recursive.
  
 
== [request_campaign_list]: Listing server contents ==
 
== [request_campaign_list]: Listing server contents ==
Line 54: Line 74:
 
*** '''uploads''': Number of uploads, including the initial upload.
 
*** '''uploads''': Number of uploads, including the initial upload.
 
*** '''[translation]'''
 
*** '''[translation]'''
**** '''language''': The name of a locale that this add-on appears to have been at least partially translated into. The following heuristic is used when an add-on is uploaded to extract a list of languages:<br>The list of directories in the uploaded campaign is recursively searched. If a directory named <code>LC_MESSAGES</code> is found then the name of the object containing this '''[dir]''' (normally the parent directory, but could be the add-on name if someone did something silly) is added to the list of translations. Directories named <code>LC_MESSAGES</code> are not searched for further matches.<br>The normal naming convention is to use POSIX locale names. This will usually be a two letter language code (e.g. <code>de</code>) or a two letter language code followed by a two letter region code (e.g. <code>pt_BR</code>). Since <code>en_US</code> is the base language, this language will not be listed as an available translation.
+
**** '''language''': The name of a locale that this add-on appears to have been at least partially translated into. The following heuristic is used when an add-on is uploaded to extract a list of languages:<br>The list of directories in the uploaded campaign is recursively searched. If a directory named <code>LC_MESSAGES</code> is found then the name of the object containing this '''[dir]''' (normally the parent directory, but could be the add-on name if someone did something silly) is added to the list of translations. Directories named <code>LC_MESSAGES</code> are not searched for further matches.<br>The normal naming convention is to use POSIX locale names. This will usually be a two letter language code (e.g. <code>de</code>) or a two letter language code followed by a two letter region code (e.g. <code>pt_BR</code>). Since <code>en_US</code> is the base language, this language will not be listed as an available translation. {{DevFeature1.15|4}} If the server finds translation files, but the translation tag is absent, it will be created but without additional data other than a supported=yes attribute.
 +
**** '''supported''': {{DevFeature1.15|4}} Is set to ''true'' if the corresponding .po or .mo localization file is found, ''false'' otherwise. Defaults to ''true'' in older addons to ensure backwards-compatibility.
 +
**** '''title''': {{DevFeature1.15|4}} The translated title of the addon.
 +
**** '''description''': {{DevFeature1.15|4}} The translated description of the addon.
  
 
== [request_campaign]: Downloading an add-on ==
 
== [request_campaign]: Downloading an add-on ==
Line 64: Line 87:
 
* '''[request_campaign]'''
 
* '''[request_campaign]'''
 
** '''name''': The name of the add-on. Note this is not the user-visible title and should not have spaces in it.
 
** '''name''': The name of the add-on. Note this is not the user-visible title and should not have spaces in it.
 +
** '''increase_downloads''': A boolean value specifying whether the download counter for the add-on should be increased or not. The game's built-in add-ons client sets this to ''false'' when downloading updates for already installed add-ons.
  
 
=== Response ===
 
=== Response ===
  
* '''author''': author(s) of the campaign.
+
* '''author''', '''description''', '''icon''', '''tags''', '''title''', '''type''', '''version''': See [[PblWML]].
* '''campaign_name''': the name of the campaign. Note this is not the title and shouldn't have spaces in it.
+
* '''campaign_name''': The name of the add-on. Note this is not the title and shouldn't have spaces in it. This corresponds to the add-on directory name on the client side.
* '''description''': description of the campaign. For pre 1.0 campaigns this should also describe the playability.
+
* '''name''': This field will always be empty. Client code would treat it as a directory name if it were not empty.
* '''icon''': path to an image in the standard image directory for Wesnoth. This path must use forward slashes (/). It cannot refer to custom images included with the campaign. It is allowed to use [[ImagePathFunctionWML]]. This image is displayed as an icon by the campaign client built into Wesnoth.
+
* '''original_timestamp''': When the first version of the add-on was uploaded. If the add-on was previously deleted from the server, this will be the time of the first reupload after the last deletion.
* '''name''': this field will always be empty. Client code would treat it as a directory name if it was not empty.
+
* '''timestamp''': When the current version of the add-on was uploaded.
* '''timestamp''': the time the campaign was last uploaded to the campaign server. This is a decimal string containing the number of seconds since the unix epoch.
+
* '''[file]''', '''[dir]''': See [[#Archive format|archive format]].
* '''title''': the title of the campaign. This is not a translatable string.
 
* '''version''': version of the campaign. The recommended format is x.y.z where x, y and z are decimal strings. x should be 0 for campaigns that are not yet complete.
 
* '''type''': indicates the type of the add-on, used for the downloads manager dialog. Possible values are described in [[PblWML]].
 
* '''[file]'''
 
** '''name''': the name of the file. This does not include any path information.
 
** '''contents''': the content of the file (binary data). This data should have no zero bytes. A byte with the code of 1 is an escape byte. The next byte will be data, but its value should be reduced by 1. Normally only byte codes of 0 and 1 are escaped.
 
* '''[dir]'''
 
** '''name''': the name of the directory. This does not include any path information.
 
** This tag may contain '''[file]''' or '''[dir]''' subtags (the latter are recursive).
 
  
 
== [upload]: Uploading an add-on ==
 
== [upload]: Uploading an add-on ==
Line 90: Line 105:
  
 
* '''[upload]'''
 
* '''[upload]'''
** '''author''': author(s) of the campaign.
+
** See tags and attributes listed in [[PblWML]].
** '''description''': description of the campaign. For pre 1.0 campaigns this should also describe the playability.
 
** '''icon''': path to an image in the standard image directory for Wesnoth. This path must use forward slashes (/). It cannot refer to custom images included with the campaign. It is allowed to use [[ImagePathFunctionWML]]. This image is displayed as an icon by the campaign client built into Wesnoth.
 
** '''name''': the name of the campaign. Note this is not the title and shouldn't have spaces in it.
 
** '''passphrase''': this is used to control updates to campaigns on the server. For existing campaigns, if the passphrase doesn't match, the update will be rejected. You can't easily change the passphrase yourself. If you lose or need to change the passphrase you need to contact the server administrator.
 
** '''email''': it is used by campaign server administrators to contact authors in case of important problems with their add-ons (incompatibilities, broken data files, violation of server [[Distributing_content#License|policies]], etc.).
 
** '''title''': the title of the campaign. This is not a translatable string.
 
** '''version''': version of the campaign. The recommended format is x.y.z where x, y and z are decimal strings. x should be 0 for campaigns that are not yet complete.
 
** '''type''': indicates the type of the add-on, used for the downloads manager dialog. Possible values are described in [[PblWML]].
 
 
** '''[data]'''
 
** '''[data]'''
*** '''[file]'''
+
*** '''[file]''', '''[dir]''': See [[#Archive format|archive format]].
**** '''name''': the name of the file. This does not include any path information.
 
**** '''contents''': the content of the file (binary data). This data should have no zero bytes. A byte with the code of 1 is an escape byte. The next byte will be data, but its value should be reduced by 1. Normally only byte codes of 0 and 1 are escaped.
 
*** '''[dir]'''
 
**** '''name''': the name of the directory. This does not include any path information.
 
**** This tag may contain '''[file]''' or '''[dir]''' subtags (the latter are recursive).
 
  
 
=== Response ===
 
=== Response ===
Line 135: Line 137:
 
** '''name''': The name of the add-on to delete.
 
** '''name''': The name of the add-on to delete.
 
** '''passphrase''': The passphrase for the add-on. It must match the passphrase on record in order for the operation to succeed.
 
** '''passphrase''': The passphrase for the add-on. It must match the passphrase on record in order for the operation to succeed.
 +
** '''uploader''': The name of the author who uploaded the add-on. Required only for add-ons using forum_auth.
  
 
=== Response ===
 
=== Response ===
Line 142: Line 145:
 
== [request_terms]: Requesting upload terms ==
 
== [request_terms]: Requesting upload terms ==
  
Retrieve the upload terms that users must accept before uploading add-ons to the server. Wesnoth requires add-ons be licensed under the GNU GPL v2 or later, with assets allowed to be licensed under the same license or a Creative Commons license.  See [[Wesnoth:Copyrights]] for more information.
+
Retrieves the upload terms that users must accept before uploading add-ons to the server. Wesnoth.org requires add-ons be licensed under the GNU GPL v2 or later, with assets allowed to be licensed under the same license or a Creative Commons license.  See [[Wesnoth:Copyrights]] for more information.
 +
 
 +
This action never fails.
  
 
=== Request ===
 
=== Request ===
Line 149: Line 154:
 
=== Response ===
 
=== Response ===
  
See [[#Common responses|Common responses]]. The <code>[message]</code> response contains the upload terms. This action never fails.
+
See [[#Common responses|Common responses]]. The <code>[message]</code> response contains the upload terms.
  
 
== See Also ==
 
== See Also ==
Line 157: Line 162:
  
 
[[Category:WML Reference]]
 
[[Category:WML Reference]]
 +
[[Category:Server Documentation]]

Latest revision as of 15:14, 7 April 2023

This page describes the WML commands exchanged between the add-ons server (campaignd) and clients.

For historical reasons, both the server software's name and the WML tags which are part of its communication protocol make exclusive reference to "campaigns" instead of "add-ons". However, in practice there is no real difference between any kind of add-ons as far as the server is concerned.

Common responses

These are WML messages sent by the server in response to any of the commands listed below.

[message]: Informational messages

This response is typically sent to confirm that an operation succeeded.

  • [message]
    • message: String containing a message for the client to display to the user.

[error]: Error messages

This response is sent when an operation has failed for any reason, whether it be a user error or an issue with the server. It is also sent upon receiving an unrecognized request.

  • [error]
    • message: String containing an error message for the client to display to the user.
    • extra_data: String containing additional information for the client to display. This is often a log of some kind (such a list of illegal filenames found during an upload request), so a client should be prepared for this to be an overlong string that might not completely fit in the screen.

Archive format

[upload] and [request_campaign] both use WML to describe archives containing the directory structure and files for each add-on. The archive format supports only regular files and directories, and file contents need to be encoded in a special fashion so that they can be serialized as WML for network transfers and disk storage.

Binary data cannot contain null characters, as well as certain special characters. In order to build escape sequences for them, a single-byte value of 0x01 is used followed by the actual byte value incremented by 1. For example, the byte sequence 0x01 0x01 is used to represent the null character 0x00, and 0x01 0xFF represents the special character 0xFE.

As of Wesnoth 1.14, the following byte values need to be escaped:

0x00 (null character), 0x01 (escape character), 0x0D (carriage return), 0xFE (used by the WML parser to encode \xFEline and \xFEtextdomain directives).

[file]: Regular file

  • name: Filename (not a relative or absolute path).
  • contents: The contents of a file encoded as binary data as described above.

[dir]: Directory

  • name: Directory name (not a relative or absolute path).
  • [file], [dir]: Regular files and subdirectories under this directory. The syntax for [dir] is recursive.

[request_campaign_list]: Listing server contents

This request is used to retrieve a list of add-ons available on the server and some overview information about them.

There are a few attributes both in the request and response WML that use timestamps. These are expected to be in secodns relative

Request

  • [request_campaign_list]
    • name: If specified and not empty, return information only for a single add-on matching this name.
    • language: Return information only about add-ons that appear to be translated into this language. These names will normally be POSIX locale names. Typically you will want to either use a two letter language code (e.g. de) or a two letter language code followed by a two character region code (e.g. pt_BR). Note that pt will not match pt_BR.
    • times_relative_to: now means that before and after below are understood to be measured in seconds relative to the time when the request is processed by campaignd. If unset or set to any other value, before and after are assumed to be in seconds relative to the Unix epoch.
    • after: Only select add-ons last updated after the indicated time. For example, to select add-ons last updated after Mon Oct 10 21:42:41 2005 UTC, you could leave times_relative_to unset and specify after=1128980561.
    • before: Only select add-ons last updated before the indicated time. For example, to select add-ons last updated over a day ago, you could specify times_relative_to="now" and before=-86400.

Response

  • timestamp: The time in seconds relative to the Unix epoch that the add-ons server reported when generating the response. You shouldn't count on this as a guarantee that no new add-ons will appear with previous update times. This could be used to detect significant clock skew or possibly used as an approximate time for how far you need to look back for updated campaigns.
  • [campaigns]
    • [campaign]
      • author, dependencies, description, icon, tags, title, translate, type, version: See PblWML.
      • downloads: The number of times the add-on (including previous versions) has been downloaded directly from the add-ons server. This does not include updates, which are handled by the official clients using the increase_downloads option to avoid bumping the downloads count; nor does it include downloads from the add-ons server web, which is handled by the web server independently.
      • feedback_url: URL to the add-on's feedback URL specified by the author in the pbl [feedback] tag and formatted according to the server's own rules. For the current add-ons server, this is a forum thread URL in the format https://r.wesnoth.org/t<TOPIC_ID>.
      • filename: The name of the file used to store the add-on archive on the server (currently the same as name).
      • name: The name of the add-on. Note this is not the title and shouldn't have spaces in it. This corresponds to the add-on directory name on the client side.
      • original_timestamp: When the first version of the add-on was uploaded. If the add-on was previously deleted from the server, this will be the time of the first reupload after the last deletion.
      • size: The on-disk size of the add-on pack in bytes on the server. If the add-on pack is stored in a compressed format, this will be the compressed size, not the uncompressed size. Because the network format currently used to send the file uses the same compression and nearly identical structure, this also happens to be almost exactly the same size transferred over the network when downloading the add-on.
      • timestamp: When the current version of the add-on was uploaded.
      • uploads: Number of uploads, including the initial upload.
      • [translation]
        • language: The name of a locale that this add-on appears to have been at least partially translated into. The following heuristic is used when an add-on is uploaded to extract a list of languages:
          The list of directories in the uploaded campaign is recursively searched. If a directory named LC_MESSAGES is found then the name of the object containing this [dir] (normally the parent directory, but could be the add-on name if someone did something silly) is added to the list of translations. Directories named LC_MESSAGES are not searched for further matches.
          The normal naming convention is to use POSIX locale names. This will usually be a two letter language code (e.g. de) or a two letter language code followed by a two letter region code (e.g. pt_BR). Since en_US is the base language, this language will not be listed as an available translation. (Version 1.15.4 and later only) If the server finds translation files, but the translation tag is absent, it will be created but without additional data other than a supported=yes attribute.
        • supported: (Version 1.15.4 and later only) Is set to true if the corresponding .po or .mo localization file is found, false otherwise. Defaults to true in older addons to ensure backwards-compatibility.
        • title: (Version 1.15.4 and later only) The translated title of the addon.
        • description: (Version 1.15.4 and later only) The translated description of the addon.

[request_campaign]: Downloading an add-on

This command is used to download the specified add-on from the server.

Request

  • [request_campaign]
    • name: The name of the add-on. Note this is not the user-visible title and should not have spaces in it.
    • increase_downloads: A boolean value specifying whether the download counter for the add-on should be increased or not. The game's built-in add-ons client sets this to false when downloading updates for already installed add-ons.

Response

  • author, description, icon, tags, title, type, version: See PblWML.
  • campaign_name: The name of the add-on. Note this is not the title and shouldn't have spaces in it. This corresponds to the add-on directory name on the client side.
  • name: This field will always be empty. Client code would treat it as a directory name if it were not empty.
  • original_timestamp: When the first version of the add-on was uploaded. If the add-on was previously deleted from the server, this will be the time of the first reupload after the last deletion.
  • timestamp: When the current version of the add-on was uploaded.
  • [file], [dir]: See archive format.

[upload]: Uploading an add-on

This command is used to upload a new add-on or an updated version of an existing one to the server.

Request

Response

See Common responses.

[change_passphrase]: Changing a passphrase

This command is used to change the passphrase for an add-on. Currently the game does not have a user interface to make use of this function. However, the Python-based wesnoth_addon_manager client included under data/tools has a --change-passphrase switch that accomplishes the same purpose.

Request

  • [change_passphrase]
    • name: The name of the add-on.
    • passphrase: The old passphrase.
    • new_passphrase: The new passphrase.

Response

See Common responses. The [message] response confirms a successful passphrase change.

[delete]: Deleting an add-on

This command is used to delete an existing add-on from the server.

Request

  • [delete]
    • name: The name of the add-on to delete.
    • passphrase: The passphrase for the add-on. It must match the passphrase on record in order for the operation to succeed.
    • uploader: The name of the author who uploaded the add-on. Required only for add-ons using forum_auth.

Response

See Common responses. The [message] response confirms the successful deletion of the add-on.

[request_terms]: Requesting upload terms

Retrieves the upload terms that users must accept before uploading add-ons to the server. Wesnoth.org requires add-ons be licensed under the GNU GPL v2 or later, with assets allowed to be licensed under the same license or a Creative Commons license. See Wesnoth:Copyrights for more information.

This action never fails.

Request

  • [request_terms]

Response

See Common responses. The [message] response contains the upload terms.

See Also

This page was last edited on 7 April 2023, at 15:14.