Stellarium  0.17.0
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  ScriptService
 Contains services related to script execution. 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


Data Structure Documentation

struct APIServiceResponse

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 explicitely 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

void APIServiceResponse::writeFile ( const QString &  path,
bool  allowCaching = false 
)
inline
Parameters
pathThe (preferably absolute) path to a file
allowCachingif true, the browser is allowed to cache the file for one hour
void APIServiceResponse::writeWrappedHTML ( const QString &  html,
const QString &  title 
)
inline
Parameters
htmlThe HTML snippet to wrap with HTML document tags
titleThe title of the page
class RemoteControlServiceInterface

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. More...
 
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

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

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 MainService, AbstractAPIService, LocationSearchService, ObjectService, SimbadService, LocationService, StelActionService, ViewService, StelPropertyService, Scenery3dRemoteControlService, and ScriptService.

virtual QLatin1String RemoteControlServiceInterface::getPath ( ) const
pure virtual
virtual bool RemoteControlServiceInterface::isThreadSafe ( ) const
pure virtual

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

Implemented in AbstractAPIService, LocationSearchService, SimbadService, and Scenery3dRemoteControlService.

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

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 MainService, AbstractAPIService, LocationService, StelActionService, StelPropertyService, ScriptService, and Scenery3dRemoteControlService.

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

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

Implemented in MainService, AbstractAPIService, and Scenery3dRemoteControlService.

class AbstractAPIService

Public Member Functions

 AbstractAPIService (QObject *parent=Q_NULLPTR)
 Only calls QObject constructor.
 
virtual bool isThreadSafe () const Q_DECL_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...
 
virtual void update (double deltaTime) Q_DECL_OVERRIDE
 Called in the main thread each frame. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
 Provides a default implementation which returns an error message.
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_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. More...
 

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

virtual bool AbstractAPIService::isThreadSafe ( ) const
virtual

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

Implements RemoteControlServiceInterface.

Reimplemented in LocationSearchService, and SimbadService.

virtual void AbstractAPIService::update ( double  deltaTime)
virtual

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

Implements RemoteControlServiceInterface.

Reimplemented in MainService.

class APIController

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

Public Member Functions

 APIController (int prefixLength, QObject *parent=Q_NULLPTR)
 Constructs an APIController. More...
 
void update (double deltaTime)
 Should be called each frame from the main thread, like from StelModule::update. More...
 
virtual void service (HttpRequest &request, HttpResponse &response)
 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 ( int  prefixLength,
QObject *  parent = Q_NULLPTR 
)
Parameters
prefixLengthDetermines how many characters to strip from the front of the request path
parentpassed on to QObject constructor

Member Function Documentation

void APIController::registerService ( RemoteControlServiceInterface service)

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

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

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.

void APIController::update ( double  deltaTime)

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

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

Public Member Functions

 LocationSearchService (QObject *parent=Q_NULLPTR)
 
virtual bool isThreadSafe () const Q_DECL_OVERRIDE
 We work on a copy of the StelLocationMgr, to prevent hitches as the web user is typing. More...
 
virtual QLatin1String getPath () const Q_DECL_OVERRIDE
 Returns the desired path mapping If there is a conflict, only the first object is mapped. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the GET method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=Q_NULLPTR)
 Only calls QObject constructor.
 
virtual void update (double deltaTime) Q_DECL_OVERRIDE
 Called in the main thread each frame. More...
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_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

virtual void LocationSearchService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
See also
GET operations

Reimplemented from AbstractAPIService.

virtual QLatin1String LocationSearchService::getPath ( ) const
inlinevirtual
virtual bool LocationSearchService::isThreadSafe ( ) const
inlinevirtual
Returns
true

Reimplemented from AbstractAPIService.

class LocationService

Public Member Functions

 LocationService (QObject *parent=Q_NULLPTR)
 
virtual QLatin1String getPath () const Q_DECL_OVERRIDE
 Returns the desired path mapping If there is a conflict, only the first object is mapped. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP GET requests. More...
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP POST requests. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=Q_NULLPTR)
 Only calls QObject constructor.
 
virtual bool isThreadSafe () const Q_DECL_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...
 
virtual void update (double deltaTime) Q_DECL_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

virtual void LocationService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
See also
GET operations

Reimplemented from AbstractAPIService.

virtual QLatin1String LocationService::getPath ( ) const
inlinevirtual
virtual void LocationService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
virtual
See also
POST operations

Reimplemented from AbstractAPIService.

class MainService

Public Types

enum  SelectionMode { Center, Zoom, Mark }
 

Public Member Functions

 MainService (QObject *parent=Q_NULLPTR)
 
virtual void update (double deltaTime) Q_DECL_OVERRIDE
 Used to implement move functionality.
 
virtual QLatin1String getPath () const Q_DECL_OVERRIDE
 Returns the desired path mapping If there is a conflict, only the first object is mapped. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the GET operations. More...
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP POST operations. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=Q_NULLPTR)
 Only calls QObject constructor.
 
virtual bool isThreadSafe () const Q_DECL_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

virtual void MainService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
See also
GET operations

Reimplemented from AbstractAPIService.

virtual QLatin1String MainService::getPath ( ) const
inlinevirtual
virtual void MainService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
virtual
See also
POST operations

Reimplemented from AbstractAPIService.

class ObjectService

Public Member Functions

 ObjectService (QObject *parent=Q_NULLPTR)
 
virtual QLatin1String getPath () const Q_DECL_OVERRIDE
 Returns the desired path mapping If there is a conflict, only the first object is mapped. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP GET method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=Q_NULLPTR)
 Only calls QObject constructor.
 
virtual bool isThreadSafe () const Q_DECL_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...
 
virtual void update (double deltaTime) Q_DECL_OVERRIDE
 Called in the main thread each frame. More...
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_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

virtual void ObjectService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
See also
GET operations

Reimplemented from AbstractAPIService.

virtual QLatin1String ObjectService::getPath ( ) const
inlinevirtual
class RemoteControl

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 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 portChanged (int val)
 
void passwordChanged (const QString &val)
 

Public Member Functions

virtual void init ()
 Initialize itself. More...
 
virtual void update (double deltaTime)
 Update the module with respect to the time. More...
 
virtual void draw (StelCore *core)
 Execute all the drawing functions for this module. More...
 
virtual double getCallOrder (StelModuleActionName actionName) const
 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...
 
virtual void handleKeys (QKeyEvent *event)
 Handle key events. More...
 
virtual bool configureGui (bool show=true)
 Detect or show the configuration GUI elements for the module. More...
 
bool getFlagEnabled () const
 
bool getFlagAutoStart () const
 
bool getFlagUsePassword () const
 
QString getPassword () const
 
int getPort () const
 
- Public Member Functions inherited from StelModule
virtual void deinit ()
 Called before the module will be delete, and before the openGL context is suppressed. 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 adress 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...
 

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...
 

Member Function Documentation

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

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.

virtual void RemoteControl::draw ( StelCore core)
virtual
Parameters
corethe core to use for the drawing

Reimplemented from StelModule.

virtual double RemoteControl::getCallOrder ( StelModuleActionName  actionName) const
virtual
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.

virtual void RemoteControl::handleKeys ( QKeyEvent *  e)
inlinevirtual

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.

virtual void RemoteControl::init ( )
virtual

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

Implements StelModule.

void RemoteControl::loadSettings ( )
slot

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()
void RemoteControl::restoreDefaultSettings ( )
slot

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

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

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

void RemoteControl::setPort ( const int  port)
slot

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

void RemoteControl::startServer ( )
slot

Uses the RequestHandler class for processing.

See also
RequestHandler
virtual void RemoteControl::update ( double  deltaTime)
virtual
Parameters
deltaTimethe time increment in second since last call.

Implements StelModule.

Property Documentation

bool RemoteControl::usePassword
readwrite

The password is passed on to the RequestHandler.

class RemoteControlStelPluginInterface

Public Member Functions

virtual StelModulegetStelModule () const
 Get the instance of StelModule to include in the list of standard StelModule.
 
virtual StelPluginInfo getPluginInfo () const
 Get information about the plugin.
 
virtual QObjectList getExtensionList () const
 A mechanism to provide abitrary QObjects to the StelModuleMgr. More...
 

Member Function Documentation

virtual QObjectList RemoteControlStelPluginInterface::getExtensionList ( ) const
inlinevirtual

Introduced to provide some limited form of inter-plugin communication. If you do not need this, return an empty list.

The StelModuleMgr remembers all loaded extensions and provides methods to access them. You should use qobject_cast to try to cast each object to a specific interface in which you are interested in.

Implements StelPluginInterface.

class RequestHandler

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 wether a password set with setPassword() is required by all requests. More...
 
bool getUsePassword ()
 Returns if a password is required to access the remote control. More...
 
void setPassword (const QString &pw)
 

Public Member Functions

 RequestHandler (const StaticFileControllerSettings &settings, QObject *parent=Q_NULLPTR)
 Constructs the request handler. More...
 
virtual ~RequestHandler ()
 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.
 
virtual void service (HttpRequest &request, HttpResponse &response)
 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 ( const StaticFileControllerSettings settings,
QObject *  parent = Q_NULLPTR 
)

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

bool RequestHandler::getUsePassword ( )
inlineslot
Warning
Make sure to only call this only when the server is offline because they are not synchronized
virtual void RequestHandler::service ( HttpRequest request,
HttpResponse response 
)
virtual

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.

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
void RequestHandler::setUsePassword ( bool  v)
slot

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
class ScriptService

Public Member Functions

 ScriptService (QObject *parent=Q_NULLPTR)
 
virtual QLatin1String getPath () const Q_DECL_OVERRIDE
 Returns the desired path mapping If there is a conflict, only the first object is mapped. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP GET method. More...
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP POST method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=Q_NULLPTR)
 Only calls QObject constructor.
 
virtual bool isThreadSafe () const Q_DECL_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...
 
virtual void update (double deltaTime) Q_DECL_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

virtual void ScriptService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
See also
GET operations

Reimplemented from AbstractAPIService.

virtual QLatin1String ScriptService::getPath ( ) const
inlinevirtual
virtual void ScriptService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
virtual
See also
POST operations

Reimplemented from AbstractAPIService.

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

Public Member Functions

 SimbadService (QObject *parent=Q_NULLPTR)
 
virtual bool isThreadSafe () const Q_DECL_OVERRIDE
 Simbad lookups dont block the main thread.
 
virtual QLatin1String getPath () const Q_DECL_OVERRIDE
 Returns the desired path mapping If there is a conflict, only the first object is mapped. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP GET method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=Q_NULLPTR)
 Only calls QObject constructor.
 
virtual void update (double deltaTime) Q_DECL_OVERRIDE
 Called in the main thread each frame. More...
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_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

virtual void SimbadService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
See also
GET operations

Reimplemented from AbstractAPIService.

virtual QLatin1String SimbadService::getPath ( ) const
inlinevirtual
class StelActionService

See also the StelAction related operations of MainService.

See also
StelAction operations (/api/stelaction/)

Public Member Functions

 StelActionService (QObject *parent=Q_NULLPTR)
 
virtual QLatin1String getPath () const Q_DECL_OVERRIDE
 Returns the desired path mapping If there is a conflict, only the first object is mapped. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP GET method. More...
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP POST method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=Q_NULLPTR)
 Only calls QObject constructor.
 
virtual bool isThreadSafe () const Q_DECL_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...
 
virtual void update (double deltaTime) Q_DECL_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

virtual void StelActionService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
See also
GET operations

Reimplemented from AbstractAPIService.

virtual QLatin1String StelActionService::getPath ( ) const
inlinevirtual
virtual void StelActionService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
virtual
See also
POST operations

Reimplemented from AbstractAPIService.

class StelPropertyService

See also the StelProperty related operations of MainService.

See also
StelProperty operations (/api/stelproperty/)

Public Member Functions

 StelPropertyService (QObject *parent=Q_NULLPTR)
 
virtual QLatin1String getPath () const Q_DECL_OVERRIDE
 Returns the desired path mapping If there is a conflict, only the first object is mapped. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP GET method. More...
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP POST method. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=Q_NULLPTR)
 Only calls QObject constructor.
 
virtual bool isThreadSafe () const Q_DECL_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...
 
virtual void update (double deltaTime) Q_DECL_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

virtual void StelPropertyService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
See also
GET operations

Reimplemented from AbstractAPIService.

virtual QLatin1String StelPropertyService::getPath ( ) const
inlinevirtual
virtual void StelPropertyService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
virtual
See also
POST operations

Reimplemented from AbstractAPIService.

class ViewService

Public Member Functions

 ViewService (QObject *parent=Q_NULLPTR)
 
virtual QLatin1String getPath () const Q_DECL_OVERRIDE
 Returns the desired path mapping If there is a conflict, only the first object is mapped. More...
 
virtual void get (const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
 Implements the HTTP GET operations. More...
 
- Public Member Functions inherited from AbstractAPIService
 AbstractAPIService (QObject *parent=Q_NULLPTR)
 Only calls QObject constructor.
 
virtual bool isThreadSafe () const Q_DECL_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...
 
virtual void update (double deltaTime) Q_DECL_OVERRIDE
 Called in the main thread each frame. More...
 
virtual void post (const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_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

virtual void ViewService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
See also
GET operations

Reimplemented from AbstractAPIService.

virtual QLatin1String ViewService::getPath ( ) const
inlinevirtual