Stellarium  23.4
Data Structures | Macros | Typedefs
Remote Control Plug-in

Control Stellarium through your web browser! For more information, see Remote Control Plug-in documentation. More...

Data Structures

struct  APIServiceResponse
 Thread-safe version of HttpResponse that can be passed around through QMetaObject::invokeMethod. More...
 
class  RemoteControlServiceInterface
 Interface for all Remote Control Plug-in services. More...
 
class  AbstractAPIService
 Abstract base class for all RemoteControlServiceInterface implementations which are provided by the Remote Control Plug-in plugin directly. More...
 
class  APIController
 This class handles the API-specific requests and dispatches them to the correct RemoteControlServiceInterface implementation. More...
 
class  LocationSearchService
 Provides predefined location search functionality, using the StelLocationMgr. More...
 
class  LocationService
 Provides methods to look up location-related information, and change the current location. More...
 
class  MainService
 Implements the main API services, including the status operation which can be repeatedly polled to find the current state of the main program, including time, view, location, StelAction and StelProperty state changes, movement, script status ... More...
 
class  ObjectService
 Provides operations to look up objects in the Stellarium catalogs. More...
 
class  RemoteControl
 Main class of the RemoteControl plug-in, implementing the StelModule interface. More...
 
class  RemoteControlStelPluginInterface
 This class defines the plugin interface with the main Stellarium program. More...
 
class  RequestHandler
 This is the main request handler for the remote control plugin, receiving and dispatching the HTTP requests. More...
 
class  SimbadService
 Allows SIMBAD object lookups like SearchDialog uses. More...
 
class  StelActionService
 Provides services related to StelAction. More...
 
class  StelPropertyService
 Provides services related to StelProperty. More...
 
class  ViewService
 Provides services related to the view (landscape, sky culture, projection). More...
 

Macros

#define RemoteControlServiceInterface_iid   "org.stellarium.plugin.RemoteSync.RemoteControlServiceInterface/1.0"
 

Typedefs

typedef QMultiMap< QByteArray, QByteArray > APIParameters
 Defines the HTTP request parameters for the service.
 

Detailed Description

Control Stellarium through your web browser! For more information, see Remote Control Plug-in documentation.


Data Structure Documentation

◆ APIServiceResponse

struct APIServiceResponse

Thread-safe version of HttpResponse that can be passed around through QMetaObject::invokeMethod.

It contains the data that will be sent back to the client in the HTTP thread, when control returns to the APIController.

Public Member Functions

 APIServiceResponse ()
 Constructs an invalid response.
 
void setHeader (const QByteArray &name, const QByteArray &val)
 Sets a specific HTTP header to the specified value.
 
void setHeader (const QByteArray &name, const int val)
 Shortcut for int header values.
 
void setCacheTime (int seconds)
 Sets the time in seconds for which the browser is allowed to cache the reply.
 
void setStatus (int status, const QByteArray &text)
 Sets the HTTP status type and status text.
 
void setData (const QByteArray &data)
 Replaces the current return data.
 
void appendData (const QByteArray &data)
 Appends to the current return data.
 
void writeRequestError (const QByteArray &msg)
 Sets the HTTP status to 400, and sets the response data to the message.
 
void writeJSON (const QJsonDocument &doc)
 Sets the Content-Type to "application/json" and serializes the given document into JSON text format.
 
void writeWrappedHTML (const QString &html, const QString &title)
 Because the HTML descriptions in Stellarium are often not compatible with "clean" HTML5 which is used for the main interface, this method can be used to explicitly wrap the given HTML snippet in a valid HTML 4.01 transitional document for better results, and include the stylesheet iframestyle.css for consistent styling when used in iframes of the RemoteControl web interface. More...
 
void writeFile (const QString &path, bool allowCaching=false)
 Writes the specified file contents into the response. More...
 

Friends

class APIController
 

Member Function Documentation

◆ writeFile()

void APIServiceResponse::writeFile ( const QString &  path,
bool  allowCaching = false 
)
inline

Writes the specified file contents into the response.

Parameters
pathThe (preferably absolute) path to a file
allowCachingif true, the browser is allowed to cache the file for one hour

◆ writeWrappedHTML()

void APIServiceResponse::writeWrappedHTML ( const QString &  html,
const QString &  title 
)
inline

Because the HTML descriptions in Stellarium are often not compatible with "clean" HTML5 which is used for the main interface, this method can be used to explicitly wrap the given HTML snippet in a valid HTML 4.01 transitional document for better results, and include the stylesheet iframestyle.css for consistent styling when used in iframes of the RemoteControl web interface.

Parameters
htmlThe HTML snippet to wrap with HTML document tags
titleThe title of the page

◆ RemoteControlServiceInterface

class RemoteControlServiceInterface

Interface for all Remote Control Plug-in services.

Each implementation is mapped to a separate HTTP request path. The get() or post() method is called to handle each request. Instances of this class which are provided through the StelModuleMgr's extension mechanism (by adding it into the list returned by StelPluginInterface::getExtensionList()) are automatically discovered and registered with the APIController.

Public Member Functions

virtual QLatin1String getPath () const =0
 Returns the desired path mapping If there is a conflict, only the first object is mapped.
 
virtual bool isThreadSafe () const =0
 Return true if the service's get() and post() methods can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response)=0
 Implement this to define reactions to HTTP GET requests. More...
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response)=0
 Implement this to define reactions to HTTP POST requests. More...
 
virtual void update (double deltaTime)=0
 Called in the main thread each frame. More...
 

Member Function Documentation

◆ get()

virtual void RemoteControlServiceInterface::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
pure virtual

Implement this to define reactions to HTTP GET requests.

GET requests generally should only query data or program state, and not change it. If there is an error with the request, use APIServiceResponse::writeRequestError to notify the client.

Parameters
operationThe operation string of the request (i.e. the part of the request URL after the service name, without parameters)
parametersThe extracted service parameters (extracted from the URL)
responseThe response object, write your response into this
Note
The thread this is called in depends on the supportThreadedOperation() return value

Implemented in Scenery3dRemoteControlService, ViewService, StelPropertyService, StelActionService, SimbadService, ObjectService, MainService, LocationService, LocationSearchService, and AbstractAPIService.

◆ isThreadSafe()

virtual bool RemoteControlServiceInterface::isThreadSafe ( ) const
pure virtual

Return true if the service's get() and post() methods can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread.

This can result in better performance if done correctly. Unless you are sure, return false here.

Implemented in Scenery3dRemoteControlService, SimbadService, LocationSearchService, and AbstractAPIService.

◆ post()

virtual void RemoteControlServiceInterface::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
pure virtual

Implement this to define reactions to HTTP POST requests.

POST requests generally should change data or perform some action. If there is an error with the request, use APIServiceResponse::writeRequestError to notify the client.

Parameters
operationThe operation string of the request (i.e. the part of the request URL after the service name, without parameters)
parametersThe extracted service parameters (extracted from the URL, and form data, if applicable)
dataThe unmodified data as sent from the client
responseThe response object, write your response into this
Note
The thread this is called in depends on the supportThreadedOperation() return value

Implemented in Scenery3dRemoteControlService, StelPropertyService, StelActionService, MainService, LocationService, and AbstractAPIService.

◆ update()

virtual void RemoteControlServiceInterface::update ( double  deltaTime)
pure virtual

Called in the main thread each frame.

Can be used for ongoing actions, for example movement control.

Implemented in Scenery3dRemoteControlService, MainService, and AbstractAPIService.

◆ AbstractAPIService

class AbstractAPIService

Abstract base class for all RemoteControlServiceInterface implementations which are provided by the Remote Control Plug-in plugin directly.

Public Member Functions

 AbstractAPIService (QObject *parent=nullptr)
 Only calls QObject constructor.
 
bool isThreadSafe () const override
 Return true if the service's get() and post() methods can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread. More...
 
void update (double deltaTime) override
 Called in the main thread each frame. More...
 
void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) override
 Provides a default implementation which returns an error message.
 
void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) override
 Provides a default implementation which returns an error message.
 
- Public Member Functions inherited from RemoteControlServiceInterface
virtual QLatin1String getPath () const =0
 Returns the desired path mapping If there is a conflict, only the first object is mapped.
 

Static Protected Attributes

static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
 This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::DirectConnection for main thread handling, or Qt::BlockingQueuedConnection for HTTP thread handling.
 

Member Function Documentation

◆ isThreadSafe()

bool AbstractAPIService::isThreadSafe ( ) const
overridevirtual

Return true if the service's get() and post() methods can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread.

This can result in better performance if done correctly. Unless you are sure, return false here.

Implements RemoteControlServiceInterface.

Reimplemented in SimbadService, and LocationSearchService.

◆ update()

void AbstractAPIService::update ( double  deltaTime)
overridevirtual

Called in the main thread each frame.

Default implementation does nothing. Can be used for ongoing actions, for example movement control.

Implements RemoteControlServiceInterface.

Reimplemented in MainService.

◆ APIController

class APIController

This class handles the API-specific requests and dispatches them to the correct RemoteControlServiceInterface implementation.

Services are registered using registerService(). To see the default services used, see the RequestHandler::RequestHandler constructor.

Public Member Functions

 APIController (int prefixLength, QObject *parent=nullptr)
 Constructs an APIController. More...
 
void update (double deltaTime)
 Should be called each frame from the main thread, like from StelModule::update. More...
 
void service (HttpRequest &request, HttpResponse &response) override
 Handles an API-specific request. More...
 
void registerService (RemoteControlServiceInterface *service)
 Registers a service with the APIController. More...
 
- Public Member Functions inherited from HttpRequestHandler
 HttpRequestHandler (QObject *parent=Q_NULLPTR)
 Constructor. More...
 
virtual ~HttpRequestHandler ()
 Destructor.
 

Constructor & Destructor Documentation

◆ APIController()

APIController::APIController ( int  prefixLength,
QObject *  parent = nullptr 
)

Constructs an APIController.

Parameters
prefixLengthDetermines how many characters to strip from the front of the request path
parentpassed on to QObject constructor

Member Function Documentation

◆ registerService()

void APIController::registerService ( RemoteControlServiceInterface service)

Registers a service with the APIController.

The RemoteControlServiceInterface::getPath() determines the request path of the service.

◆ service()

void APIController::service ( HttpRequest request,
HttpResponse response 
)
overridevirtual

Handles an API-specific request.

It finds out which RemoteControlServiceInterface to use depending on the service name (first part of path until slash). An error is returned for invalid requests. If a service was found, the request is passed on to its RemoteControlServiceInterface::get or RemoteControlServiceInterface::post method depending on the HTTP request type. If RemoteControlServiceInterface::isThreadSafe is false, these methods are called in the Stellarium main thread using QMetaObject::invokeMethod, otherwise they are directly executed in the current thread (HTTP worker thread).

Reimplemented from HttpRequestHandler.

◆ update()

void APIController::update ( double  deltaTime)

Should be called each frame from the main thread, like from StelModule::update.

Passed on to each AbstractAPIService::update method for optional processing.

◆ LocationSearchService

class LocationSearchService

Provides predefined location search functionality, using the StelLocationMgr.

See also
LocationSearchService operations (/api/locationsearch/), LocationService
Note
This service supports threaded operation

Public Member Functions

 LocationSearchService (QObject *parent=nullptr)
 
bool isThreadSafe () const override
 We work on a copy of the StelLocationMgr, to prevent hitches as the web user is typing. More...
 
QLatin1String getPath () const override
 Returns the desired path mapping If there is a conflict, only the first object is mapped.
 
void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) override
 Implements the GET method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=nullptr)
 Only calls QObject constructor.
 
void update (double deltaTime) override
 Called in the main thread each frame. More...
 
void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) override
 Provides a default implementation which returns an error message.
 

Additional Inherited Members

- Static Protected Attributes inherited from AbstractAPIService
static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
 This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::DirectConnection for main thread handling, or Qt::BlockingQueuedConnection for HTTP thread handling.
 

Member Function Documentation

◆ get()

void LocationSearchService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
overridevirtual

Implements the GET method.

See also
GET operations

Reimplemented from AbstractAPIService.

◆ isThreadSafe()

bool LocationSearchService::isThreadSafe ( ) const
inlineoverridevirtual

We work on a copy of the StelLocationMgr, to prevent hitches as the web user is typing.

Returns
true

Reimplemented from AbstractAPIService.

◆ LocationService

class LocationService

Provides methods to look up location-related information, and change the current location.

See also
LocationService operations (/api/location/), LocationService

Public Member Functions

 LocationService (QObject *parent=nullptr)
 
QLatin1String getPath () const override
 Returns the desired path mapping If there is a conflict, only the first object is mapped.
 
void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) override
 Implements the HTTP GET requests. More...
 
void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) override
 Implements the HTTP POST requests. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=nullptr)
 Only calls QObject constructor.
 
bool isThreadSafe () const override
 Return true if the service's get() and post() methods can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread. More...
 
void update (double deltaTime) override
 Called in the main thread each frame. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from AbstractAPIService
static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
 This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::DirectConnection for main thread handling, or Qt::BlockingQueuedConnection for HTTP thread handling.
 

Member Function Documentation

◆ get()

void LocationService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
overridevirtual

Implements the HTTP GET requests.

See also
GET operations

Reimplemented from AbstractAPIService.

◆ post()

void LocationService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
overridevirtual

Implements the HTTP POST requests.

See also
POST operations

Reimplemented from AbstractAPIService.

◆ MainService

class MainService

Implements the main API services, including the status operation which can be repeatedly polled to find the current state of the main program, including time, view, location, StelAction and StelProperty state changes, movement, script status ...

See also
MainService operations (/api/main/)

Public Types

enum  SelectionMode { Center , Zoom , Mark }
 

Public Member Functions

 MainService (QObject *parent=nullptr)
 
void update (double deltaTime) override
 Used to implement move functionality.
 
QLatin1String getPath () const override
 Returns the desired path mapping If there is a conflict, only the first object is mapped.
 
void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) override
 Implements the GET operations. More...
 
void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) override
 Implements the HTTP POST operations. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=nullptr)
 Only calls QObject constructor.
 
bool isThreadSafe () const override
 Return true if the service's get() and post() methods can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from AbstractAPIService
static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
 This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::DirectConnection for main thread handling, or Qt::BlockingQueuedConnection for HTTP thread handling.
 

Member Function Documentation

◆ get()

void MainService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
overridevirtual

Implements the GET operations.

See also
GET operations

Reimplemented from AbstractAPIService.

◆ post()

void MainService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
overridevirtual

Implements the HTTP POST operations.

See also
POST operations

Reimplemented from AbstractAPIService.

◆ ObjectService

class ObjectService

Provides operations to look up objects in the Stellarium catalogs.

See also
ObjectService operations (/api/objects/)

Public Member Functions

 ObjectService (QObject *parent=nullptr)
 
QLatin1String getPath () const override
 Returns the desired path mapping If there is a conflict, only the first object is mapped.
 
void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) override
 Implements the HTTP GET method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=nullptr)
 Only calls QObject constructor.
 
bool isThreadSafe () const override
 Return true if the service's get() and post() methods can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread. More...
 
void update (double deltaTime) override
 Called in the main thread each frame. More...
 
void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) override
 Provides a default implementation which returns an error message.
 

Additional Inherited Members

- Static Protected Attributes inherited from AbstractAPIService
static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
 This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::DirectConnection for main thread handling, or Qt::BlockingQueuedConnection for HTTP thread handling.
 

Member Function Documentation

◆ get()

void ObjectService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
overridevirtual

Implements the HTTP GET method.

See also
GET operations

Reimplemented from AbstractAPIService.

◆ RemoteControl

class RemoteControl

Main class of the RemoteControl plug-in, implementing the StelModule interface.

Manages the settings and the starting/stopping of the QtWebApp web server. The RequestHandler class is used for request processing.

Author
Florian Schaukowitsch

Public Slots

void setFlagEnabled (bool b)
 Starts/stops the web server.
 
void setFlagAutoStart (bool b)
 If true, the server is automatically started when init() is called.
 
void setFlagUsePassword (bool b)
 If true, the password from setPassword() is required for all web requests.
 
void setPassword (const QString &password)
 Sets the password that is optionally enabled with setFlagUsePassword(). More...
 
void setFlagEnableCors (bool b)
 If true, Access-Control-Allow-Origin header will be appended to responses.
 
void setCorsOrigin (const QString &corsOrigin)
 Sets the CORS origin that is optionally enabled with setFlagEnableCors().
 
void setPort (const int port)
 Sets the port where the server listens. More...
 
void loadSettings ()
 Load the plug-in's settings from the configuration file. More...
 
void saveSettings ()
 Save the plug-in's settings to the configuration file. More...
 
void restoreDefaultSettings ()
 Restore the plug-in's settings to the default state. More...
 
void startServer ()
 Starts the HTTP server using the current settings and begins handling requests. More...
 
void stopServer ()
 Stops the HTTP server gracefully.
 

Signals

void flagEnabledChanged (bool val)
 
void flagAutoStartChanged (bool val)
 
void flagUsePasswordChanged (bool val)
 
void flagEnableCorsChanged (bool val)
 
void portChanged (int val)
 
void passwordChanged (const QString &val)
 
void corsOriginChanged (const QString &val)
 

Public Member Functions

void init () override
 Initialize itself. More...
 
void update (double deltaTime) override
 Update the module with respect to the time. More...
 
void draw (StelCore *core) override
 Execute all the drawing functions for this module. More...
 
double getCallOrder (StelModuleActionName actionName) const override
 Return the value defining the order of call for the given action For example if stars.callOrder[ActionDraw] == 10 and constellation.callOrder[ActionDraw] == 11, the stars module will be drawn before the constellations. More...
 
void handleKeys (QKeyEvent *event) override
 Handle key events. More...
 
bool configureGui (bool show=true) override
 Detect or show the configuration GUI elements for the module. More...
 
bool getFlagEnabled () const
 
bool getFlagAutoStart () const
 
bool getFlagUsePassword () const
 
bool getFlagEnableCors () const
 
QString getPassword () const
 
QString getCorsOrigin () const
 
int getPort () const
 
- Public Member Functions inherited from StelModule
 StelModule ()
 Constructor. Every derived class MUST call setObjectName(className) in its constructor.
 
virtual void deinit ()
 Called before the module will be deleted, and before the OpenGL context is suppressed. More...
 
virtual QSettings * getSettings ()
 Return module-specific settings. More...
 
virtual QString getModuleVersion () const
 Get the version of the module, default is stellarium main version.
 
virtual QString getAuthorName () const
 Get the name of the module author.
 
virtual QString getAuthorEmail () const
 Get the email address of the module author.
 
virtual void handleMouseClicks (class QMouseEvent *)
 Handle mouse clicks. More...
 
virtual void handleMouseWheel (class QWheelEvent *)
 Handle mouse wheel. More...
 
virtual bool handleMouseMoves (int x, int y, Qt::MouseButtons b)
 Handle mouse moves. More...
 
virtual bool handlePinch (qreal scale, bool started)
 Handle pinch gesture events. More...
 

Properties

bool enabled
 Determines if the web server is running, and can be used to start/stop the server.
 
bool autoStart
 If true, the server is automatically started when init() is called.
 
bool usePassword
 If true, the password set with setPassword() is required for all requests. More...
 
bool enableCors
 

Additional Inherited Members

- Public Types inherited from StelModule
enum  StelModuleSelectAction { AddToSelection , ReplaceSelection , RemoveFromSelection }
 Enum used when selecting objects to define whether to add to, replace, or remove from the existing selection list. More...
 
enum  StelModuleActionName {
  ActionDraw , ActionUpdate , ActionHandleMouseClicks , ActionHandleMouseMoves ,
  ActionHandleKeys
}
 Define the possible action for which an order is defined. More...
 
- Protected Member Functions inherited from StelModule
class StelActionaddAction (const QString &id, const QString &groupId, const QString &text, QObject *target, const char *slot, const QString &shortcut="", const QString &altShortcut="")
 convenience methods to add an action (call to slot) to the StelActionMgr object. More...
 
class StelActionaddAction (const QString &id, const QString &groupId, const QString &text, const char *slot, const QString &shortcut="", const QString &altShortcut="")
 convenience methods to add an action (call to own slot) to the StelActionMgr object. More...
 
StelActionaddAction (const QString &id, const QString &groupId, const QString &text, QObject *contextObject, std::function< void()> lambda, const QString &shortcut="", const QString &altShortcut="")
 convenience methods to add an action (call to Lambda functor) to the StelActionMgr object. More...
 

Member Function Documentation

◆ configureGui()

bool RemoteControl::configureGui ( bool  show = true)
overridevirtual

Detect or show the configuration GUI elements for the module.

This is to be used with plugins to display a configuration dialog from the plugin list window.

Parameters
showif true, make the configuration GUI visible. If false, hide the config GUI if there is one.
Returns
true if the module has a configuration GUI, else false.

Reimplemented from StelModule.

◆ draw()

void RemoteControl::draw ( StelCore core)
overridevirtual

Execute all the drawing functions for this module.

Parameters
corethe core to use for the drawing

Reimplemented from StelModule.

◆ getCallOrder()

double RemoteControl::getCallOrder ( StelModuleActionName  actionName) const
overridevirtual

Return the value defining the order of call for the given action For example if stars.callOrder[ActionDraw] == 10 and constellation.callOrder[ActionDraw] == 11, the stars module will be drawn before the constellations.

Parameters
actionNamethe name of the action for which we want the call order
Returns
the value defining the order. The closer to 0 the earlier the module's action will be called

Reimplemented from StelModule.

◆ handleKeys()

void RemoteControl::handleKeys ( QKeyEvent *  e)
inlineoverridevirtual

Handle key events.

Please note that most of the interactions will be done through the GUI module.

Parameters
ethe Key event
Returns
set the event as accepted if it was intercepted

Reimplemented from StelModule.

◆ init()

void RemoteControl::init ( )
overridevirtual

Initialize itself.

If the initialization takes significant time, the progress should be displayed on the loading bar.

Implements StelModule.

◆ loadSettings

void RemoteControl::loadSettings ( )
slot

Load the plug-in's settings from the configuration file.

Settings are kept in the "RemoteControl" section in Stellarium's configuration file. If no such section exists, it will load default values.

See also
saveSettings(), restoreDefaultSettings()

◆ restoreDefaultSettings

void RemoteControl::restoreDefaultSettings ( )
slot

Restore the plug-in's settings to the default state.

Replace the plug-in's settings in Stellarium's configuration file with the default values and re-load them. Uses internally loadSettings() and saveSettings().

◆ saveSettings

void RemoteControl::saveSettings ( )
slot

Save the plug-in's settings to the configuration file.

See also
loadSettings(), restoreDefaultSettings()

◆ setPassword

void RemoteControl::setPassword ( const QString &  password)
slot

Sets the password that is optionally enabled with setFlagUsePassword().

The password is required by RequestHandler for all HTTP requests. Basic HTTP auth is used, without a user name.

◆ setPort

void RemoteControl::setPort ( const int  port)
slot

Sets the port where the server listens.

Must be done before startServer() is called, or restart the server to use the new setting.

◆ startServer

void RemoteControl::startServer ( )
slot

Starts the HTTP server using the current settings and begins handling requests.

Uses the RequestHandler class for processing.

See also
RequestHandler

◆ update()

void RemoteControl::update ( double  deltaTime)
overridevirtual

Update the module with respect to the time.

Parameters
deltaTimethe time increment in second since last call.

Reimplemented from StelModule.

Property Documentation

◆ usePassword

bool RemoteControl::usePassword
readwrite

If true, the password set with setPassword() is required for all requests.

The password is passed on to the RequestHandler.

◆ RemoteControlStelPluginInterface

class RemoteControlStelPluginInterface

This class defines the plugin interface with the main Stellarium program.

Public Member Functions

StelModulegetStelModule () const override
 Get the instance of StelModule to include in the list of standard StelModule.
 
StelPluginInfo getPluginInfo () const override
 Get information about the plugin.
 
- Public Member Functions inherited from StelPluginInterface
virtual QObjectList getExtensionList () const
 A mechanism to provide arbitrary QObjects to the StelModuleMgr. More...
 

◆ RequestHandler

class RequestHandler

This is the main request handler for the remote control plugin, receiving and dispatching the HTTP requests.

It also handles the optional simple HTTP authentication. See service to find out how the requests are processed.

Public Slots

void setUsePassword (bool v)
 Sets whether a password set with setPassword() is required by all requests. More...
 
bool getUsePassword ()
 Returns if a password is required to access the remote control.
 
void setPassword (const QString &pw)
 
void setEnableCors (bool v)
 Sets whether CORS is enabled. More...
 
bool getEnableCors () const
 Returns if CORS is enabled.
 
void setCorsOrigin (const QString &origin)
 Set the host for which CORS is enabled. More...
 

Public Member Functions

 RequestHandler (const StaticFileControllerSettings &settings, QObject *parent=nullptr)
 Constructs the request handler. More...
 
 ~RequestHandler () override
 The internal APIController, and all registered services are deleted.
 
void update (double deltaTime)
 Called in the main thread each frame, only passed on to APIController::update.
 
void service (HttpRequest &request, HttpResponse &response) override
 Receives the HttpRequest from the HttpListener. More...
 
- Public Member Functions inherited from HttpRequestHandler
 HttpRequestHandler (QObject *parent=Q_NULLPTR)
 Constructor. More...
 
virtual ~HttpRequestHandler ()
 Destructor.
 

Constructor & Destructor Documentation

◆ RequestHandler()

RequestHandler::RequestHandler ( const StaticFileControllerSettings settings,
QObject *  parent = nullptr 
)

Constructs the request handler.

This also creates an StaticFileController for the webroot folder, and an APIController.

To see the default services that are registered here, see API reference.

Member Function Documentation

◆ service()

void RequestHandler::service ( HttpRequest request,
HttpResponse response 
)
overridevirtual

Receives the HttpRequest from the HttpListener.

It checks the optional HTTP authentication and sets the keep-alive header if requested by the client.

If the authentication is correct, the request is processed according to the following rules:

  • If the request path starts with the string "/api/", then the request is passed to the APIController without further processing.
  • If a file specified in the special translate_files file is requested, the cached translated version of this file is returned. This cache is updated each time the app language changes.
  • Otherwise, it is passed to a StaticFileController that has been set up for the data/webroot folder.
Note
This method runs in an HTTP worker thread, not in the Stellarium main thread, so take caution.

Reimplemented from HttpRequestHandler.

◆ setCorsOrigin

void RequestHandler::setCorsOrigin ( const QString &  origin)
slot

Set the host for which CORS is enabled.

Specify "*" to let any website take control.

Warning
Make sure to only call this only when the server is offline because they are not synchronized

◆ setEnableCors

void RequestHandler::setEnableCors ( bool  v)
slot

Sets whether CORS is enabled.

Warning
Make sure to only call this only when the server is offline because they are not synchronized

◆ setPassword

void RequestHandler::setPassword ( const QString &  pw)
slot
Warning
Make sure to only call this only when the server is offline because they are not synchronized

◆ setUsePassword

void RequestHandler::setUsePassword ( bool  v)
slot

Sets whether a password set with setPassword() is required by all requests.

It uses HTTP Basic authorization, with an empty username.

Warning
Make sure to only call this only when the server is offline because they are not synchronized

◆ SimbadService

class SimbadService

Allows SIMBAD object lookups like SearchDialog uses.

See also
SimbadService operations (/api/simbad/)
Note
This service supports threaded operation.

Public Member Functions

 SimbadService (QObject *parent=nullptr)
 
bool isThreadSafe () const override
 Simbad lookups dont block the main thread.
 
QLatin1String getPath () const override
 Returns the desired path mapping If there is a conflict, only the first object is mapped.
 
void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) override
 Implements the HTTP GET method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=nullptr)
 Only calls QObject constructor.
 
void update (double deltaTime) override
 Called in the main thread each frame. More...
 
void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) override
 Provides a default implementation which returns an error message.
 

Additional Inherited Members

- Static Protected Attributes inherited from AbstractAPIService
static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
 This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::DirectConnection for main thread handling, or Qt::BlockingQueuedConnection for HTTP thread handling.
 

Member Function Documentation

◆ get()

void SimbadService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
overridevirtual

Implements the HTTP GET method.

See also
GET operations

Reimplemented from AbstractAPIService.

◆ StelActionService

class StelActionService

Provides services related to StelAction.

See also the StelAction related operations of MainService.

See also
StelAction operations (/api/stelaction/)

Public Member Functions

 StelActionService (QObject *parent=nullptr)
 
QLatin1String getPath () const override
 Returns the desired path mapping If there is a conflict, only the first object is mapped.
 
void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) override
 Implements the HTTP GET method. More...
 
void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) override
 Implements the HTTP POST method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=nullptr)
 Only calls QObject constructor.
 
bool isThreadSafe () const override
 Return true if the service's get() and post() methods can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread. More...
 
void update (double deltaTime) override
 Called in the main thread each frame. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from AbstractAPIService
static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
 This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::DirectConnection for main thread handling, or Qt::BlockingQueuedConnection for HTTP thread handling.
 

Member Function Documentation

◆ get()

void StelActionService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
overridevirtual

Implements the HTTP GET method.

See also
GET operations

Reimplemented from AbstractAPIService.

◆ post()

void StelActionService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
overridevirtual

Implements the HTTP POST method.

See also
POST operations

Reimplemented from AbstractAPIService.

◆ StelPropertyService

class StelPropertyService

Provides services related to StelProperty.

See also the StelProperty related operations of MainService.

See also
StelProperty operations (/api/stelproperty/)

Public Member Functions

 StelPropertyService (QObject *parent=nullptr)
 
QLatin1String getPath () const override
 Returns the desired path mapping If there is a conflict, only the first object is mapped.
 
void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) override
 Implements the HTTP GET method. More...
 
void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) override
 Implements the HTTP POST method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=nullptr)
 Only calls QObject constructor.
 
bool isThreadSafe () const override
 Return true if the service's get() and post() methods can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread. More...
 
void update (double deltaTime) override
 Called in the main thread each frame. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from AbstractAPIService
static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
 This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::DirectConnection for main thread handling, or Qt::BlockingQueuedConnection for HTTP thread handling.
 

Member Function Documentation

◆ get()

void StelPropertyService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
overridevirtual

Implements the HTTP GET method.

See also
GET operations

Reimplemented from AbstractAPIService.

◆ post()

void StelPropertyService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
overridevirtual

Implements the HTTP POST method.

See also
POST operations

Reimplemented from AbstractAPIService.

◆ ViewService

class ViewService

Provides services related to the view (landscape, sky culture, projection).

See also
ViewService operations (/api/view/)

Public Member Functions

 ViewService (QObject *parent=nullptr)
 
QLatin1String getPath () const override
 Returns the desired path mapping If there is a conflict, only the first object is mapped.
 
void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) override
 Implements the HTTP GET operations. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=nullptr)
 Only calls QObject constructor.
 
bool isThreadSafe () const override
 Return true if the service's get() and post() methods can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread. More...
 
void update (double deltaTime) override
 Called in the main thread each frame. More...
 
void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) override
 Provides a default implementation which returns an error message.
 

Additional Inherited Members

- Static Protected Attributes inherited from AbstractAPIService
static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
 This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::DirectConnection for main thread handling, or Qt::BlockingQueuedConnection for HTTP thread handling.
 

Member Function Documentation

◆ get()

void ViewService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
overridevirtual

Implements the HTTP GET operations.

See also
GET operations

Reimplemented from AbstractAPIService.