Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
JSONRPC::CJSONServiceDescription Class Reference

Helper class for json schema service descriptor based service descriptions for the json rpc API. More...

#include <JSONServiceDescription.h>

Inheritance diagram for JSONRPC::CJSONServiceDescription:
JSONRPC::CJSONUtils

Static Public Member Functions

static bool AddType (const std::string &jsonType)
 Parses the given json schema description and evaluates and stores the defined type.
 
static bool AddMethod (const std::string &jsonMethod, MethodCall method)
 Parses the given json schema description and evaluates and stores the defined method.
 
static bool AddBuiltinMethod (const std::string &jsonMethod)
 Parses the given json schema description and evaluates and stores the defined builtin method.
 
static bool AddNotification (const std::string &jsonNotification)
 Parses the given json schema description and evaluates and stores the defined notification.
 
static bool AddEnum (const std::string &name, const std::vector< CVariant > &values, CVariant::VariantType type=CVariant::VariantTypeNull, const CVariant &defaultValue=CVariant::ConstNullVariant)
 
static bool AddEnum (const std::string &name, const std::vector< std::string > &values)
 
static bool AddEnum (const std::string &name, const std::vector< int > &values)
 
static const char * GetVersion ()
 Gets the version of the json schema description.
 
static JSONRPC_STATUS Print (CVariant &result, ITransportLayer *transport, IClient *client, bool printDescriptions=true, bool printMetadata=false, bool filterByTransport=true, const std::string &filterByName="", const std::string &filterByType="", bool printReferences=true)
 Prints the json schema description into the given result object.
 
static JSONRPC_STATUS CheckCall (const char *method, const CVariant &requestParameters, ITransportLayer *transport, IClient *client, bool notification, MethodCall &methodCall, CVariant &outputParameters)
 Checks the given parameters from the request against the json schema description for the given method.
 
static JSONSchemaTypeDefinitionPtr GetType (const std::string &identification)
 
static void ResolveReferences ()
 
static void Cleanup ()
 
- Static Public Member Functions inherited from JSONRPC::CJSONUtils
static void MillisecondsToTimeObject (int time, CVariant &result)
 

Friends

class JSONSchemaTypeDefinition
 
class JsonRpcMethod
 

Additional Inherited Members

- Static Protected Member Functions inherited from JSONRPC::CJSONUtils
static void HandleLimits (const CVariant &parameterObject, CVariant &result, int size, int &start, int &end)
 
static bool ParseSorting (const CVariant &parameterObject, SortBy &sortBy, SortOrder &sortOrder, SortAttribute &sortAttributes)
 
static void ParseLimits (const CVariant &parameterObject, int &limitStart, int &limitEnd)
 
static bool ParameterExists (const CVariant &parameterObject, const std::string &key, unsigned int position)
 Checks if the given object contains a parameter.
 
static bool IsValueMember (const CVariant &value, const std::string &key)
 Checks if the given object contains a value with the given key.
 
static CVariant GetParameter (const CVariant &parameterObject, const std::string &key, unsigned int position)
 Returns the json value of a parameter.
 
static CVariant GetParameter (const CVariant &parameterObject, const std::string &key, unsigned int position, const CVariant &fallback)
 Returns the json value of a parameter or the given default value.
 
static std::string GetString (const CVariant &value, const char *defaultValue)
 Returns the given json value as a string.
 
static TransportLayerCapability StringToTransportLayer (const std::string &transport)
 Returns a TransportLayerCapability value of the given string representation.
 
static JSONSchemaType StringToSchemaValueType (const std::string &valueType)
 Returns a JSONSchemaType value for the given string representation.
 
static std::string SchemaValueTypeToString (JSONSchemaType valueType)
 Returns a string representation for the given JSONSchemaType.
 
static void SchemaValueTypeToJson (JSONSchemaType valueType, CVariant &jsonObject)
 Converts the given json schema type into a json object.
 
static const char * ValueTypeToString (CVariant::VariantType valueType)
 
static bool IsParameterType (const CVariant &parameterObject, const char *key, unsigned int position, JSONSchemaType valueType)
 Checks if the parameter with the given name or at the given position is of a certain type.
 
static bool IsType (const CVariant &value, JSONSchemaType valueType)
 Checks if the given json value is of the given type.
 
static void SetDefaultValue (CVariant &value, JSONSchemaType valueType)
 Sets the value of the given json value to the default value of the given type.
 
static bool HasType (JSONSchemaType typeObject, JSONSchemaType type)
 
static bool ParameterNotNull (const CVariant &parameterObject, const std::string &key)
 
static void CopyStringArray (const CVariant &jsonStringArray, std::vector< std::string > &stringArray)
 Copies the values from the jsonStringArray to the stringArray. stringArray is cleared.
 
static void SetFromDBDate (const CVariant &jsonDate, CDateTime &date)
 
static void SetFromDBDateTime (const CVariant &jsonDate, CDateTime &date)
 
static bool GetXspFiltering (const std::string &type, const CVariant &filter, std::string &xsp)
 

Detailed Description

Helper class for json schema service descriptor based service descriptions for the json rpc API.

Provides static functions to parse a complete json schema service descriptor of a published service containing json rpc methods, print the json schema service descriptor representation into a string (mainly for output purposes) and evaluate and verify parameters provided in a call to one of the publish json rpc methods against a parameter definition parsed from a json schema service descriptor.

Member Function Documentation

◆ AddBuiltinMethod()

bool CJSONServiceDescription::AddBuiltinMethod ( const std::string & jsonMethod)
static

Parses the given json schema description and evaluates and stores the defined builtin method.

Parameters
jsonMethodjson schema description to parse
Returns
True if the json schema description has been parsed successfully otherwise false

◆ AddEnum() [1/3]

bool CJSONServiceDescription::AddEnum ( const std::string & name,
const std::vector< CVariant > & values,
CVariant::VariantType type = CVariant::VariantTypeNull,
const CVariant & defaultValue = CVariant::ConstNullVariant )
static

◆ AddEnum() [2/3]

bool CJSONServiceDescription::AddEnum ( const std::string & name,
const std::vector< int > & values )
static

◆ AddEnum() [3/3]

bool CJSONServiceDescription::AddEnum ( const std::string & name,
const std::vector< std::string > & values )
static

◆ AddMethod()

bool CJSONServiceDescription::AddMethod ( const std::string & jsonMethod,
MethodCall method )
static

Parses the given json schema description and evaluates and stores the defined method.

Parameters
jsonMethodjson schema description to parse
methodpointer to the implementation
Returns
True if the json schema description has been parsed successfully otherwise false

◆ AddNotification()

bool CJSONServiceDescription::AddNotification ( const std::string & jsonNotification)
static

Parses the given json schema description and evaluates and stores the defined notification.

Parameters
jsonNotificationjson schema description to parse
Returns
True if the json schema description has been parsed successfully otherwise false

◆ AddType()

bool CJSONServiceDescription::AddType ( const std::string & jsonType)
static

Parses the given json schema description and evaluates and stores the defined type.

Parameters
jsonTypejson schema description to parse
Returns
True if the json schema description has been parsed successfully otherwise false

◆ CheckCall()

JSONRPC_STATUS CJSONServiceDescription::CheckCall ( const char * method,
const CVariant & requestParameters,
ITransportLayer * transport,
IClient * client,
bool notification,
MethodCall & methodCall,
CVariant & outputParameters )
static

Checks the given parameters from the request against the json schema description for the given method.

Parameters
methodCalled method
requestParametersParameters from the request
clientClient who sent the request
notificationWhether the request was sent as a notification or not
methodCallObject which will contain the actual C/C++ method to be called
outputParametersCleaned up parameter list
Returns
OK if the validation of the request succeeded otherwise an appropriate error code

Checks if the given method is a valid json rpc method, if the client has the permission to call this method, if the method can be called as a notification or not, assigns the actual C/C++ implementation of the method to the "methodCall" parameter and checks the given parameters from the request against the json schema description for the given method.

◆ Cleanup()

void CJSONServiceDescription::Cleanup ( )
static

◆ GetType()

JSONSchemaTypeDefinitionPtr CJSONServiceDescription::GetType ( const std::string & identification)
static

◆ GetVersion()

const char * CJSONServiceDescription::GetVersion ( )
static

Gets the version of the json schema description.

Returns
Version of the json schema description

◆ Print()

JSONRPC_STATUS CJSONServiceDescription::Print ( CVariant & result,
ITransportLayer * transport,
IClient * client,
bool printDescriptions = true,
bool printMetadata = false,
bool filterByTransport = true,
const std::string & filterByName = "",
const std::string & filterByType = "",
bool printReferences = true )
static

Prints the json schema description into the given result object.

Parameters
resultObject into which the json schema description is printed
transportTransport layer capabilities
clientClient requesting a print
printDescriptionsWhether to print descriptions or not
printMetadataWhether to print XBMC specific data or not
filterByTransportWhether to filter by transport or not

◆ ResolveReferences()

void CJSONServiceDescription::ResolveReferences ( )
static

Friends And Related Symbol Documentation

◆ JsonRpcMethod

friend class JsonRpcMethod
friend

◆ JSONSchemaTypeDefinition

friend class JSONSchemaTypeDefinition
friend

The documentation for this class was generated from the following files: