Stellarium  1.2
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
 
class  LocationSearchService
 
class  LocationService
 
class  MainService
 
class  ObjectService
 
class  RemoteControl
 
class  RemoteControlStelPluginInterface
 
class  RequestHandler
 This is the main request handler for the remote control plugin, receiving and dispatching the HTTP requests. More...
 
class  SimbadService
 
class  StelActionService
 
class  StelPropertyService
 
class  ViewService
 

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

◆ APIServiceResponse

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 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
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
Parameters
htmlThe HTML snippet to wrap with HTML document tags
titleThe title of the page

◆ RemoteControlServiceInterface

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

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, and Scenery3dRemoteControlService.

◆ isThreadSafe()

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.

◆ post()

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, and Scenery3dRemoteControlService.

◆ update()

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

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

Implemented in MainService, AbstractAPIService, and Scenery3dRemoteControlService.

◆ AbstractAPIService

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.
 

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()

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.

◆ update()

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.

◆ 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=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) Q_DECL_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 = Q_NULLPTR 
)
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)

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

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

◆ update()

void APIController::update ( double  deltaTime)

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

◆ get()

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

Reimplemented from AbstractAPIService.

◆ isThreadSafe()

virtual bool LocationSearchService::isThreadSafe ( ) const
inlinevirtual
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=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.
 
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

◆ get()

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

Reimplemented from AbstractAPIService.

◆ post()

virtual void LocationService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
virtual
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=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.
 
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

◆ get()

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

Reimplemented from AbstractAPIService.

◆ post()

virtual void MainService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
virtual
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=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.
 
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

◆ get()

virtual void ObjectService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
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

virtual void init () Q_DECL_OVERRIDE
 Initialize itself. More...
 
virtual void update (double deltaTime) Q_DECL_OVERRIDE
 Update the module with respect to the time. More...
 
virtual void draw (StelCore *core) Q_DECL_OVERRIDE
 Execute all the drawing functions for this module. More...
 
virtual double getCallOrder (StelModuleActionName actionName) const Q_DECL_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...
 
virtual void handleKeys (QKeyEvent *event) Q_DECL_OVERRIDE
 Handle key events. More...
 
virtual bool configureGui (bool show=true) Q_DECL_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()

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.

◆ draw()

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

Reimplemented from StelModule.

◆ getCallOrder()

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.

◆ handleKeys()

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.

◆ init()

virtual void RemoteControl::init ( )
virtual

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

Implements StelModule.

◆ loadSettings

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()

◆ 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().

◆ saveSettings

void RemoteControl::saveSettings ( )
slot

◆ setPassword

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.

◆ setPort

void RemoteControl::setPort ( const int  port)
slot

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

◆ startServer

void RemoteControl::startServer ( )
slot

Uses the RequestHandler class for processing.

See also
RequestHandler

◆ update()

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

Reimplemented from StelModule.

Property Documentation

◆ usePassword

bool RemoteControl::usePassword
readwrite

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

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

Member Function Documentation

◆ getExtensionList()

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.

◆ RequestHandler

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

◆ service()

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.

◆ setCorsOrigin

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

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

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

◆ get()

virtual void SimbadService::get ( const QByteArray &  operation,
const APIParameters parameters,
APIServiceResponse response 
)
virtual
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=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.
 
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

◆ get()

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

Reimplemented from AbstractAPIService.

◆ post()

virtual void StelActionService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
virtual
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=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.
 
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

◆ get()

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

Reimplemented from AbstractAPIService.

◆ post()

virtual void StelPropertyService::post ( const QByteArray &  operation,
const APIParameters parameters,
const QByteArray &  data,
APIServiceResponse response 
)
virtual
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=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.
 
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

◆ get()

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

Reimplemented from AbstractAPIService.