/* This header SHOULD NOT be included by other headers in this directory. */
-#include <IService.h>
+#include <ISystemService.h>
#include <IServiceRunner.h>
#include <IClient.h>
#include <IMethodCallHandler.h>
class StoreManager;
- class EXPORT_API ContextStoreService : public IService {
+ class EXPORT_API ContextStoreService : public ISystemService {
public:
ContextStoreService();
~ContextStoreService();
+ // Inherited from IService
void setServiceRunner(IServiceRunner* runner);
-
- bool isUserService();
-
const char* getServiceName();
const char* getMethodSpecs();
+ IMethodCallHandler* createMethodCallHandler(IClient* client);
+ // Inherited from ISystemService
bool prepare();
void cleanup();
+ void onUserActivated(uid_t uid);
+ void onUserDeactivated(uid_t uid);
- void onUserActivated();
- void onUserDeactivated();
-
- IMethodCallHandler* createMethodCallHandler(IClient* client);
-
- GMainContext* getMainContext();
-
+ // Own members
StoreManager* getStoreManager();
private:
{
}
-bool ContextStoreService::isUserService()
+const char* ContextStoreService::getServiceName()
{
- return false;
+ return NULL;
}
-const char* ContextStoreService::getServiceName()
+const char* ContextStoreService::getMethodSpecs()
{
return NULL;
}
-const char* ContextStoreService::getMethodSpecs()
+IMethodCallHandler* ContextStoreService::createMethodCallHandler(IClient* client)
{
return NULL;
}
{
}
-void ContextStoreService::onUserActivated()
-{
-}
-
-void ContextStoreService::onUserDeactivated()
+void ContextStoreService::onUserActivated(uid_t uid)
{
}
-IMethodCallHandler* ContextStoreService::createMethodCallHandler(IClient* client)
+void ContextStoreService::onUserDeactivated(uid_t uid)
{
- return NULL;
}
StoreManager* ContextStoreService::getStoreManager()
if (isSystem)
return manager.getSystemStore(uri);
- else if (util::getActiveUid() != ROOT_UID)
+ else
return manager.getUserStore(uri);
-
- _W("No active user");
- return NULL;
}
ContextStoreService* ContextStore::__hostService = NULL;
* limitations under the License.
*/
-#include <ServerUtil.h>
#include <ContextStoreTypesPrivate.h>
#include <ContextStore.h>
#include <ContextStoreService.h>
__serviceRunner = runner;
}
-bool ContextStoreService::isUserService()
-{
- return false;
-}
-
const char* ContextStoreService::getServiceName()
{
return CTX_CONTEXT_STORE;
return CTX_CONTEXT_STORE_SPEC;
}
+IMethodCallHandler* ContextStoreService::createMethodCallHandler(IClient* client)
+{
+ return new MethodCallHandler(client);
+}
+
bool ContextStoreService::prepare()
{
if (!DatabaseManager::openSystem())
DatabaseManager::closeSystem();
}
-void ContextStoreService::onUserActivated()
+void ContextStoreService::onUserActivated(uid_t uid)
{
- if (!DatabaseManager::openUser(util::getActiveUid()))
+ // TODO: Need to support a normal user and a container user simultaneously.
+ if (!DatabaseManager::openUser(uid))
return;
UserSchemaLoader schemaLoader;
schemaLoader.load();
}
-void ContextStoreService::onUserDeactivated()
+void ContextStoreService::onUserDeactivated(uid_t uid)
{
DatabaseManager::closeUser();
if (__storeManager)
__storeManager->flushUserCache();
}
-IMethodCallHandler* ContextStoreService::createMethodCallHandler(IClient* client)
-{
- return new MethodCallHandler(client);
-}
-
-GMainContext* ContextStoreService::getMainContext()
-{
- return __serviceRunner->getMainContext();
-}
-
StoreManager* ContextStoreService::getStoreManager()
{
if (__storeManager)
void MethodCallHandler::onMethodCalled(IMethodCall* methodCall)
{
try {
- __verifyUid(methodCall->getUid());
std::string uri = __getStoreUri(methodCall->getParam());
Store* store = __getStore(uri);
{
}
-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::__getStoreUri(GVariant* param)
{
const char* uri = NULL;
void onDisconnected();
private:
- void __verifyUid(uid_t uid);
std::string __getStoreUri(GVariant* param);
StoreManager& __getStoreManager();
Store* __getStore(const std::string& uri);