using namespace ctx;
namespace {
- class JobIdGenerator {
- public:
- void init(JobInfoDatabase& database);
- int pop();
- private:
- void __push(int id);
- std::deque<int> __usedIds;
- };
+class JobIdGenerator {
+public:
+ void init(JobInfoDatabase& database);
+ int pop();
+private:
+ void __push(int id);
+ std::deque<int> __usedIds;
+};
}
void JobIdGenerator::init(JobInfoDatabase& database)
if (jobInfo->getType() == JobInfo::Type::PERIODIC) {
jobId = __addPeriodicJob(static_cast<PeriodicJobInfo*>(jobInfo), owner);
-
} else if (jobInfo->getType() == JobInfo::Type::ON_DEMAND) {
jobId = __addOnDemandJob(static_cast<OnDemandJobInfo*>(jobInfo), owner);
-
} else {
return E_PARAM;
}
void JobManager::__verifyPeriodicJob(PeriodicJobInfo* jobInfo, IClient* owner)
{
IF_FAIL_THROW_TAG(!(jobInfo->isOneTime() && jobInfo->isPersistent()), E_PARAM,
- _W, "A one-time job cannot be persistent.");
+ _W, "A one-time job cannot be persistent.");
IF_FAIL_THROW_TAG(jobInfo->getInterval() >= CTX_MIN_JOB_PERIOD, E_PARAM,
- _W, "The interval is too short.");
+ _W, "The interval is too short.");
IF_FAIL_THROW_TAG(jobInfo->getInterval() <= CTX_MAX_JOB_PERIOD, E_PARAM,
- _W, "The interval is too long.");
+ _W, "The interval is too long.");
IF_FAIL_THROW_TAG(jobInfo->getAnchor() >= 0, E_PARAM,
- _W, "The anchor should be positive.");
+ _W, "The anchor should be positive.");
__verifyRequirements(jobInfo, owner);
__verifyAction(jobInfo, owner);
void JobManager::__verifyOnDemandJob(OnDemandJobInfo* jobInfo, IClient* owner)
{
IF_FAIL_THROW_TAG(!(jobInfo->isOneTime() && jobInfo->isPersistent()), E_PARAM,
- _W, "A one-time job cannot be persistent.");
+ _W, "A one-time job cannot be persistent.");
__verifyTriggers(jobInfo, owner);
__verifyRequirements(jobInfo, owner);
_D("Check %s", uri.c_str());
IF_FAIL_THROW_TAG(isSupported(JobContext::Type::TRIGGER, uri, owner), E_SUPPORT,
- _W, "'%s' is not supported.", uri.c_str());
+ _W, "'%s' is not supported.", uri.c_str());
IF_FAIL_THROW_TAG(__isPermitted(uri, owner), E_ACCESS,
- _W, "'%s' is not allowed to use '%s'.", owner->getName().c_str(), uri.c_str());
+ _W, "'%s' is not allowed to use '%s'.", owner->getName().c_str(), uri.c_str());
}
}
void JobManager::__verifyRequirements(JobInfo* jobInfo, IClient* owner)
{
IF_FAIL_THROW_TAG(jobInfo->getRequirementTimeout() <= CTX_MAX_REQ_TIMEOUT, E_PARAM,
- _W, "The requirement timeout is too short.");
+ _W, "The requirement timeout is too short.");
for (auto& req : jobInfo->getRequirements()) {
const std::string& uri = req->getUri();
_D("Check %s", uri.c_str());
IF_FAIL_THROW_TAG(isSupported(JobContext::Type::REQUIREMENT, uri, owner), E_SUPPORT,
- _W, "'%s' is not supported.", uri.c_str());
+ _W, "'%s' is not supported.", uri.c_str());
IF_FAIL_THROW_TAG(__isPermitted(uri, owner), E_ACCESS,
- _W, "'%s' is not allowed to use '%s'.", owner->getName().c_str(), uri.c_str());
+ _W, "'%s' is not allowed to use '%s'.", owner->getName().c_str(), uri.c_str());
}
}
return;
}
- // DBus Method
- verified = [&]()->bool {
- JobDBusCall* dbusAction = dynamic_cast<JobDBusCall*>(action);
- IF_FAIL_RETURN(dbusAction, false);
- IF_FAIL_RETURN(!(dbusAction->getBusName().empty()), false);
- IF_FAIL_RETURN(!(dbusAction->getObjectPath().empty()), false);
- IF_FAIL_RETURN(!(dbusAction->getInterface().empty()), false);
- IF_FAIL_RETURN(!(dbusAction->getMethodName().empty()), false);
- return true;
- }();
- if (verified) return;
+ //TODO: DBus Method is not supported due to security issue.
_W("Invalid action");
throw E_PARAM;