AccountServices API JSDoc

This commit is contained in:
David Rowe 2019-02-15 08:00:19 +13:00
parent 54e36f0825
commit 2a338124ae
2 changed files with 68 additions and 13 deletions

View file

@ -112,6 +112,12 @@ DownloadInfoResult::DownloadInfoResult() :
{ {
} }
/**jsdoc
* Information on the assets currently being downloaded and pending download.
* @typedef {object} AccountServices.DownloadInfoResult
* @property {number[]} downloading - The percentage complete for each asset currently being downloaded.
* @property {number} pending - The number of assets waiting to be download.
*/
QScriptValue DownloadInfoResultToScriptValue(QScriptEngine* engine, const DownloadInfoResult& result) { QScriptValue DownloadInfoResultToScriptValue(QScriptEngine* engine, const DownloadInfoResult& result) {
QScriptValue object = engine->newObject(); QScriptValue object = engine->newObject();

View file

@ -38,16 +38,24 @@ class AccountServicesScriptingInterface : public QObject {
Q_OBJECT Q_OBJECT
/**jsdoc /**jsdoc
* The AccountServices API contains helper functions related to user connectivity * The <code>AccountServices</code> API provides functions related to user connectivity, visibility, and asset download
* progress.
* *
* @hifi-interface * @hifi-interface
* @hifi-client-entity * @hifi-client-entity
* *
* @namespace AccountServices * @namespace AccountServices
* @property {string} username <em>Read-only.</em> * @property {string} username - The user name if the user is logged in, otherwise <code>"Unknown user"</code>.
* @property {boolean} loggedIn <em>Read-only.</em> * <em>Read-only.</em>
* @property {string} findableBy * @property {boolean} loggedIn - <code>true</code> if the user is logged in, otherwise <code>false</code>.
* @property {string} metaverseServerURL <em>Read-only.</em> * <em>Read-only.</em>
* @property {string} findableBy - The user's visibility to other people:<br />
* <code>"none"</code> - user appears offline.<br />
* <code>"friends"</code> - user is visible only to friends.<br />
* <code>"connections"</code> - user is visible to friends and connections.<br />
* <code>"all"</code> - user is visible to everyone.
* @property {string} metaverseServerURL - The metaverse server that the user is authenticated against when logged in
* &mdash; typically <code>"https://metaverse.highfidelity.com"</code>. <em>Read-only.</em>
*/ */
Q_PROPERTY(QString username READ getUsername NOTIFY myUsernameChanged) Q_PROPERTY(QString username READ getUsername NOTIFY myUsernameChanged)
@ -65,29 +73,38 @@ public:
public slots: public slots:
/**jsdoc /**jsdoc
* Get information on the progress of downloading assets in the domain.
* @function AccountServices.getDownloadInfo * @function AccountServices.getDownloadInfo
* @returns {DownloadInfoResult} * @returns {AccountServices.DownloadInfoResult} Information on the progress of assets download.
*/ */
DownloadInfoResult getDownloadInfo(); DownloadInfoResult getDownloadInfo();
/**jsdoc /**jsdoc
* Cause a {@link AccountServices.downloadInfoChanged|downloadInfoChanged} signal to be triggered with information on the
* current progress of the download of assets in the domain.
* @function AccountServices.updateDownloadInfo * @function AccountServices.updateDownloadInfo
*/ */
void updateDownloadInfo(); void updateDownloadInfo();
/**jsdoc /**jsdoc
* Check whether the user is logged in.
* @function AccountServices.isLoggedIn * @function AccountServices.isLoggedIn
* @returns {boolean} * @returns {boolean} <code>true</code> if the user is logged in, <code>false</code> otherwise.
* @example <caption>Report whether you are logged in.</caption>
* var isLoggedIn = AccountServices.isLoggedIn();
* print("You are logged in: " + isLoggedIn); // true or false
*/ */
bool isLoggedIn(); bool isLoggedIn();
/**jsdoc /**jsdoc
* Prompts the user to log in (the login dialog is displayed) if they're not already logged in.
* @function AccountServices.checkAndSignalForAccessToken * @function AccountServices.checkAndSignalForAccessToken
* @returns {boolean} * @returns {boolean} <code>true</code> if the user is already logged in, <code>false</code> otherwise.
*/ */
bool checkAndSignalForAccessToken(); bool checkAndSignalForAccessToken();
/**jsdoc /**jsdoc
* Logs the user out.
* @function AccountServices.logOut * @function AccountServices.logOut
*/ */
void logOut(); void logOut();
@ -105,43 +122,75 @@ private slots:
signals: signals:
/**jsdoc /**jsdoc
* Not currently used.
* @function AccountServices.connected * @function AccountServices.connected
* @returns {Signal} * @returns {Signal}
*/ */
void connected(); void connected();
/**jsdoc /**jsdoc
* Triggered when the user logs out.
* @function AccountServices.disconnected * @function AccountServices.disconnected
* @param {string} reason * @param {string} reason - Has the value, <code>"logout"</code>.
* @returns {Signal} * @returns {Signal}
*/ */
void disconnected(const QString& reason); void disconnected(const QString& reason);
/**jsdoc /**jsdoc
* Triggered when the username logged in with changes, i.e., when the user logs in or out.
* @function AccountServices.myUsernameChanged * @function AccountServices.myUsernameChanged
* @param {string} username * @param {string} username - The username logged in with if the user is logged in, otherwise <code>""</code>.
* @returns {Signal} * @returns {Signal}
* @example <caption>Report when your username changes.</caption>
* AccountServices.myUsernameChanged.connect(function (username) {
* print("Username changed: " + username);
* });
*/ */
void myUsernameChanged(const QString& username); void myUsernameChanged(const QString& username);
/**jsdoc /**jsdoc
* Triggered when the progress of the download of assets for the domain changes.
* @function AccountServices.downloadInfoChanged * @function AccountServices.downloadInfoChanged
* @param {} info * @param {AccountServices.DownloadInfoResult} downloadInfo - Information on the progress of assets download.
* @returns {Signal} * @returns {Signal}
*/ */
void downloadInfoChanged(DownloadInfoResult info); void downloadInfoChanged(DownloadInfoResult info);
/**jsdoc /**jsdoc
* Triggered when the user's visibility to others changes.
* @function AccountServices.findableByChanged * @function AccountServices.findableByChanged
* @param {string} discoverabilityMode * @param {string} findableBy - The user's visibility to other people:<br />
* <code>"none"</code> - user appears offline.<br />
* <code>"friends"</code> - user is visible only to friends.<br />
* <code>"connections"</code> - user is visible to friends and connections.<br />
* <code>"all"</code> - user is visible to everyone.
* @returns {Signal} * @returns {Signal}
* @example <caption>Report when your visiblity changes.</caption>
* AccountServices.findableByChanged.connect(function (findableBy) {
* print("Findable by changed: " + findableBy);
* });
*
* var originalFindableBy = AccountServices.findableBy;
* Script.setTimeout(function () {
* // Change visiblity.
* AccountServices.findableBy = originalFindableBy === "none" ? "all" : "none";
* }, 2000);
* Script.setTimeout(function () {
* // Restore original visibility.
* AccountServices.findableBy = originalFindableBy;
* }, 4000);
*/ */
void findableByChanged(const QString& discoverabilityMode); void findableByChanged(const QString& discoverabilityMode);
/**jsdoc /**jsdoc
* Triggered when the login status of the user changes.
* @function AccountServices.loggedInChanged * @function AccountServices.loggedInChanged
* @param {boolean} loggedIn * @param {boolean} loggedIn - <code>true</code> if the user is logged in, otherwise <code>false</code>.
* @returns {Signal} * @returns {Signal}
* @example <caption>Report when your login status changes.</caption>
* AccountServices.loggedInChanged.connect(function(loggedIn) {
* print("Logged in: " + loggedIn);
* });
*/ */
void loggedInChanged(bool loggedIn); void loggedInChanged(bool loggedIn);