Skip to content
Permalink
Browse files

ServicesAPI: make the list of parameters available to methods

This is useful for any methods that allow for optional parameters in the
request to know which parameters have been set and which haven't and are
therefore set to some default value.

You use the lower cased name of the parameter so for example to check if
'Title' is present you would use something like this:

if (m_parsedParams.contains("title"))
{
...
}

Signed-off-by: Paul Harrison <pharrison@mythtv.org>
  • Loading branch information...
dizygotheca authored and Paul Harrison committed Mar 18, 2017
1 parent 4298254 commit 681a33766aeed02f63295a8a613c5e70cb5b714d
Showing with 10 additions and 0 deletions.
  1. +3 −0 mythtv/libs/libmythservicecontracts/service.h
  2. +7 −0 mythtv/libs/libmythupnp/servicehost.cpp
@@ -62,6 +62,9 @@ class SERVICE_PUBLIC Service : public QObject

static bool ToBool( const QString &sVal );

public:

QList<QString> m_parsedParams; // lowercased
};

//////////////////////////////////////////////////////////////////////////////
@@ -51,6 +51,13 @@ QVariant MethodInfo::Invoke( Service *pService, const QStringMap &reqParams )
lowerParams[it.key().toLower()] = *it;
}

// --------------------------------------------------------------
// Provide actual parameters received to method
// --------------------------------------------------------------

pService->m_parsedParams = lowerParams.keys();


QList<QByteArray> paramNames = m_oMethod.parameterNames();
QList<QByteArray> paramTypes = m_oMethod.parameterTypes();

0 comments on commit 681a337

Please sign in to comment.
You can’t perform that action at this time.