/* This header SHOULD NOT be included by other headers in this directory. */
-#include <IService.h>
+#include <IUserService.h>
#include <IServiceRunner.h>
#include <IClient.h>
#include <IMethodCallHandler.h>
namespace ctx {
- class EXPORT_API SensorRecorderService : public IService {
+ class EXPORT_API SensorRecorderService : public IUserService {
public:
SensorRecorderService();
~SensorRecorderService();
+ // Inherited from IService
void setServiceRunner(IServiceRunner* runner);
-
- bool isUserService();
-
const char* getServiceName();
const char* getMethodSpecs();
-
- bool prepare();
- void cleanup();
-
- void onUserActivated();
- void onUserDeactivated();
-
IMethodCallHandler* createMethodCallHandler(IClient* client);
+ // Inherited from IUserService
+ bool prepare(uid_t uid);
+ void cleanup(uid_t uid);
+
+ // Own members
GDBusConnection* getConnection();
private:
{
}
-bool SensorRecorderService::isUserService()
-{
- return true;
-}
-
const char* SensorRecorderService::getServiceName()
{
return NULL;
return NULL;
}
-bool SensorRecorderService::prepare()
-{
- return false;
-}
-
-void SensorRecorderService::cleanup()
+IMethodCallHandler* SensorRecorderService::createMethodCallHandler(IClient* client)
{
+ return NULL;
}
-void SensorRecorderService::onUserActivated()
+bool SensorRecorderService::prepare(uid_t uid)
{
+ return false;
}
-void SensorRecorderService::onUserDeactivated()
+void SensorRecorderService::cleanup(uid_t uid)
{
}
-IMethodCallHandler* SensorRecorderService::createMethodCallHandler(IClient* client)
+GDBusConnection* SensorRecorderService::getConnection()
{
return NULL;
}
void MethodCallHandler::onMethodCalled(IMethodCall* methodCall)
{
try {
- __verifyUid(methodCall->getUid());
std::string subject = __extractParameter(methodCall->getParam(), IDX_SUBJECT);
_D("%s(%s)", methodCall->getMethodName().c_str(), subject.c_str());
{
}
-void MethodCallHandler::__verifyUid(uid_t uid)
-{
- if (!util::isSystemUid(uid) && uid != util::getActiveUid()) {
- _E("Invalid Uid: %u != %u (ActiveUser)", uid, util::getActiveUid());
- throw static_cast<int>(E_ACCESS);
- }
-}
-
std::string MethodCallHandler::__extractParameter(GVariant* param, unsigned int idx)
{
const char* val = NULL;
void onDisconnected();
private:
- void __verifyUid(uid_t uid);
std::string __extractParameter(GVariant* param, unsigned int idx);
void __startRecording(SensorProvider& provider, IMethodCall& methodCall);
void __stopRecording(SensorProvider& provider, IMethodCall& methodCall);
* limitations under the License.
*/
-#include <ServerUtil.h>
#include <SensorRecorderTypesPrivate.h>
#include <SensorRecorderService.h>
#include "MethodCallHandler.h"
__serviceRunner = runner;
}
-bool SensorRecorderService::isUserService()
-{
- return true;
-}
-
const char* SensorRecorderService::getServiceName()
{
return CTX_SENSOR_RECORDER;
return CTX_SENSOR_RECORDER_SPEC;
}
-bool SensorRecorderService::prepare()
+IMethodCallHandler* SensorRecorderService::createMethodCallHandler(IClient* client)
+{
+ return new MethodCallHandler(client);
+}
+
+bool SensorRecorderService::prepare(uid_t uid)
{
RecorderClientInfo::setHostService(this);
- if (!SensorDatabase::open(util::getActiveUid()))
+ if (!SensorDatabase::open(uid))
return false;
SensorTimer::init();
return true;
}
-void SensorRecorderService::cleanup()
+void SensorRecorderService::cleanup(uid_t uid)
{
SensorProvider::release();
SensorTimer::release();
SensorDatabase::close();
}
-void SensorRecorderService::onUserActivated()
-{
-}
-
-void SensorRecorderService::onUserDeactivated()
-{
-}
-
-IMethodCallHandler* SensorRecorderService::createMethodCallHandler(IClient* client)
-{
- return new MethodCallHandler(client);
-}
-
GDBusConnection* SensorRecorderService::getConnection()
{
return __serviceRunner->getConnection();