Stellarium 0.15.2
|
Abstract base class for all Remote Control Plug-in service implementations. More...
#include <AbstractAPIService.hpp>
Public Member Functions | |
AbstractAPIService (const QByteArray &serviceName, QObject *parent=0) | |
Abstract constructor. The service name is used by the APIController for request path mapping. More... | |
QByteArray | serviceName () |
Returns the service name, used for request path mapping by the APIController. More... | |
virtual bool | supportsThreadedOperation () const |
Return true if the service 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) |
Called in the main thread each frame. More... | |
Q_INVOKABLE APIServiceResponse | get (const QByteArray &operation, const APIParameters ¶meters) |
Wrapper around getImpl(), constructs an APIServiceResponse object for the response and passes it on. More... | |
Q_INVOKABLE APIServiceResponse | post (const QByteArray &operation, const APIParameters ¶meters, const QByteArray &data) |
Wrapper around postImpl(), constructs an APIServiceResponse object for the response and passes it on. More... | |
Protected Member Functions | |
virtual void | getImpl (const QByteArray &operation, const APIParameters ¶meters, APIServiceResponse &response) |
Subclasses should implement this to define reactions to HTTP GET requests. More... | |
virtual void | postImpl (const QByteArray &operation, const APIParameters ¶meters, const QByteArray &data, APIServiceResponse &response) |
Subclasses should implement this to define reactions to HTTP POST requests. More... | |
QString | wrapHtml (QString &text, const QString &title) const |
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 set the doctype to 4.01 transitional for better results, and include the stylesheet iframestyle.css . 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. More... | |
Abstract base class for all Remote Control Plug-in service implementations.
Different implementations of this class are mapped to different HTTP request paths. For each API request, the APIController finds out which service to use, and calls its get() or post() method.
Definition at line 89 of file AbstractAPIService.hpp.
|
inline |
Abstract constructor. The service name is used by the APIController for request path mapping.
Definition at line 94 of file AbstractAPIService.hpp.
Q_INVOKABLE APIServiceResponse AbstractAPIService::get | ( | const QByteArray & | operation, |
const APIParameters & | parameters | ||
) |
Wrapper around getImpl(), constructs an APIServiceResponse object for the response and passes it on.
|
protectedvirtual |
Subclasses should 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.
operation | The operation string of the request (i.e. the part of the request URL after the service name, without parameters) |
parameters | The extracted service parameters (extracted from the URL) |
response | The response object, write your response into this |
Reimplemented in MainService, LocationSearchService, ObjectService, SimbadService, LocationService, StelActionService, ViewService, ScriptService, and StelPropertyService.
Q_INVOKABLE APIServiceResponse AbstractAPIService::post | ( | const QByteArray & | operation, |
const APIParameters & | parameters, | ||
const QByteArray & | data | ||
) |
Wrapper around postImpl(), constructs an APIServiceResponse object for the response and passes it on.
|
protectedvirtual |
Subclasses should 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.
operation | The operation string of the request (i.e. the part of the request URL after the service name, without parameters) |
parameters | The extracted service parameters (extracted from the URL, and form data, if applicable) |
data | The unmodified data as sent from the client |
response | The response object, write your response into this |
Reimplemented in MainService, LocationService, StelActionService, ScriptService, and StelPropertyService.
|
inline |
Returns the service name, used for request path mapping by the APIController.
Definition at line 102 of file AbstractAPIService.hpp.
|
virtual |
Return true if the service can safely be run in the HTTP handler thread, instead of having to queue it into the Stellarium main thread.
Default implementation returns false, i.e. no special threading precautions have to be used in the get() and post() implementation.
FORCE_THREADED_SERVICES
is set, all services will be run in the HTTP threads for testing, and this method will be ignored. Reimplemented in LocationSearchService, and SimbadService.
|
virtual |
Called in the main thread each frame.
Default implementation does nothing. Can be used for ongoing actions, for example movement control.
Reimplemented in MainService.
|
protected |
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 set the doctype to 4.01 transitional for better results, and include the stylesheet iframestyle.css
.
text | The text to wrap with HTML document tags |
title | The title of the page |
|
staticprotected |
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.
Definition at line 144 of file AbstractAPIService.hpp.