Partial implementation of API: functions requiring no IPC 01/133701/3
authorMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 13 Jun 2017 06:57:26 +0000 (15:57 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 13 Jun 2017 07:25:53 +0000 (16:25 +0900)
Change-Id: Ic217d22b8020affc56b44ef0dd36457555fd567e
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
include/job_scheduler_internal.h
src/client/job_scheduler.cpp

index 4f21df55754c2df8c6744ce02c186c2f2ff07b19..716bc9accf65c8c737fcd648c6374b7dc3b84415 100644 (file)
@@ -49,6 +49,7 @@ typedef struct _ctx_sched_job_context_s* ctx_sched_job_context_h;
 
 /**
  * @brief      Called for each registered job.
+ * @remarks    @c job should be destroyed using ctx_sched_job_destroy().
  * @param[in]  scheduler       TBD
  * @param[in]  job                     TBD
  * @param[in]  user_data       TBD
@@ -60,6 +61,7 @@ typedef bool (*ctx_sched_foreach_job_cb)(ctx_sched_h scheduler, ctx_sched_job_h
  * @brief      Called when a job needs to be stopped.
  * @details In some reason, the device may no longer allow executions of scheduled jobs.
  *                     This function is invoked to notify such circumstances.
+ * @remarks    @c job should be destroyed using ctx_sched_job_destroy().
  * @param[in]  scheduler       TBD
  * @param[in]  job                     TBD
  * @param[in]  user_data       TBD
@@ -84,7 +86,7 @@ int ctx_sched_destroy(ctx_sched_h scheduler);
 
 /**
  * @brief      Schedules a job.
- * @details    This internally registers the job using ctx_sched_add_job() and starts it using ctx_sched_start_job().
+ * @details    This function internally registers the job using ctx_sched_add_job() and starts it using ctx_sched_start_job().
  * @param[in]  scheduler       TBD
  * @param[in]  job                     TBD
  * @param[out] job_id          TBD
@@ -94,7 +96,7 @@ int ctx_sched_schedule(ctx_sched_h scheduler, ctx_sched_job_h job, int* job_id);
 
 /**
  * @brief      Cancels a scheduled job.
- * @details    This internally stops the job using ctx_sched_stop_job() and unregisters it using ctx_sched_remove_job().
+ * @details    This function internally stops the job using ctx_sched_stop_job() and unregisters it using ctx_sched_remove_job().
  * @param[in]  scheduler       TBD
  * @param[in]  job_id          TBD
  * @return     @c 0 on success, otherwise a negative error value
@@ -172,35 +174,9 @@ int ctx_sched_foreach_job(ctx_sched_h scheduler, ctx_sched_foreach_job_cb callba
 int ctx_sched_set_stop_job_cb(ctx_sched_h scheduler, ctx_sched_stop_job_cb callback, void* user_data);
 
 
-/**
- * @brief      Declares a custom context that can be used as a trigger or a requirement by other applications.
- * @param[in]  scheduler       TBD
- * @param[in]  uri                     TBD
- * @return     @c 0 on success, otherwise a negative error value
- */
-int ctx_sched_declare_context(ctx_sched_h scheduler, const char* uri);
-
-/**
- * @brief      Retracts a custom context declared by the current application.
- * @param[in]  scheduler       TBD
- * @param[in]  uri                     TBD
- * @return     @c 0 on success, otherwise a negative error value
- */
-int ctx_sched_undeclare_context(ctx_sched_h scheduler, const char* uri);
-
-/**
- * @brief      Publishes a custom context data corresponding to a URI declared using ctx_sched_declare_context().
- * @param[in]  scheduler               TBD
- * @param[in]  uri                             TBD
- * @param[in]  json_payload    TBD
- * @return     @c 0 on success, otherwise a negative error value
- */
-int ctx_sched_publish_context_json(ctx_sched_h scheduler, const char* uri, const char* json_payload);
-
-
 /**
  * @brief      Creates a periodic job handle.
- * @param[in]  interval        Periodic interval
+ * @param[in]  interval        Periodic interval (minutes)
  * @param[in]  anchor          Reference time that the periodic timer starts with
  * @param[out] job                     Job handle
  * @return     @c 0 on success, otherwise a negative error value
@@ -284,12 +260,16 @@ int ctx_sched_job_set_dbus(ctx_sched_job_h job, const char* bus_name,
                const char* object_path, const char* interface, const char* method, GVariant* parameters);
 
 /**
- * @brief      Attaches the bundle that can be retrieved using ctx_sched_job_get_bundle().
+ * @brief      Attaches user data that can be retrieved using ctx_sched_job_get_user_data().
+ * @details    A Null-terminate string can be attached to a job. The attached string can be accessed
+ *                     using ctx_sched_job_get_user_data(), after acquiring a job handle using ctx_sched_get_job().
+ *                     Note that, the string should be a valid Json data string, i.e., containing no double-quotes
+ *                     and other Json special characters.
  * @param[in]  job                     Job handle
- * @param[in]  user_bundle     Bundle
+ * @param[in]  user_data       User data
  * @return     @c 0 on success, otherwise a negative error value
  */
-int ctx_sched_job_set_bundle(ctx_sched_job_h job, bundle* user_bundle);
+int ctx_sched_job_set_user_data(ctx_sched_job_h job, const char* user_data);
 
 
 /**
@@ -309,12 +289,14 @@ int ctx_sched_job_is_started(ctx_sched_job_h job, bool* started);
 int ctx_sched_job_get_id(ctx_sched_job_h job, int* job_id);
 
 /**
- * @brief      Gets the bundle attached to a job
+ * @brief      Gets the user data string attached to a job
+ * @details    This function returns a pointer to the string contained in the @c job.
+ *                     The @c job should be not freed unless you do not reference the @c user_data anymore.
  * @param[in]  job                     Job handle
- * @param[out] user_bundle     Bundle
+ * @param[out] user_data       User data string
  * @return     @c 0 on success, otherwise a negative error value
  */
-int ctx_sched_job_get_bundle(ctx_sched_job_h job, bundle** user_bundle);
+int ctx_sched_job_get_user_data(ctx_sched_job_h job, const char** user_data);
 
 
 /**
@@ -354,98 +336,98 @@ int ctx_sched_job_requirement_create(const char* uri, bool optional, ctx_sched_j
 /**
  * @brief      Prepares an attribute of a context.
  * @param[in]  job_context     Context handle
- * @param[in]  attribute       Name of attribute
+ * @param[in]  name            Name of attribute
  * @return     @c 0 on success, otherwise a negative error value
  */
-int ctx_sched_job_context_prepare_attribute_int(ctx_sched_job_context_h job_context, const char* attribute);
+int ctx_sched_job_context_prepare_attribute_int(ctx_sched_job_context_h job_context, const char name);
 
 /**
  * @brief      Prepares an attribute of a context.
  * @param[in]  job_context     Context handle
- * @param[in]  attribute       Name of attribute
+ * @param[in]  name            Name of attribute
  * @return     @c 0 on success, otherwise a negative error value
  */
-int ctx_sched_job_context_prepare_attribute_str(ctx_sched_job_context_h job_context, const char* attribute);
+int ctx_sched_job_context_prepare_attribute_str(ctx_sched_job_context_h job_context, const char name);
 
 /**
  * @brief      Adds an equal-to condition of a context attribute.
  * @param[in]  job_context     Context handle
- * @param[in]  attribute       Name of attribute
+ * @param[in]  name            Name of attribute
  * @param[in]  value           Value to be compared
  * @return     @c 0 on success, otherwise a negative error value
  * @pre                ctx_sched_job_context_prepare_attribute()
  */
-int ctx_sched_job_context_attribute_add_eq_int(ctx_sched_job_context_h job_context, const char* attribute, int value);
+int ctx_sched_job_context_attribute_add_eq_int(ctx_sched_job_context_h job_context, const char name, int value);
 
 /**
  * @brief      Adds an equal-to condition of a context attribute.
  * @param[in]  job_context     Context handle
- * @param[in]  attribute       Name of attribute
+ * @param[in]  name            Name of attribute
  * @param[in]  value           Value to be compared
  * @return     @c 0 on success, otherwise a negative error value
  * @pre                ctx_sched_job_context_prepare_attribute()
  */
-int ctx_sched_job_context_attribute_add_eq_str(ctx_sched_job_context_h job_context, const char* attribute, const char* value);
+int ctx_sched_job_context_attribute_add_eq_str(ctx_sched_job_context_h job_context, const char name, const char* value);
 
 /**
  * @brief      Adds a not-equal-to condition of a context attribute.
  * @param[in]  job_context     Context handle
- * @param[in]  attribute       Name of attribute
+ * @param[in]  name            Name of attribute
  * @param[in]  value           Value to be compared
  * @return     @c 0 on success, otherwise a negative error value
  * @pre                ctx_sched_job_context_prepare_attribute()
  */
-int ctx_sched_job_context_attribute_add_ne_int(ctx_sched_job_context_h job_context, const char* attribute, int value);
+int ctx_sched_job_context_attribute_add_ne_int(ctx_sched_job_context_h job_context, const char name, int value);
 
 /**
  * @brief      Adds a not-equal-to condition of a context attribute.
  * @param[in]  job_context     Context handle
- * @param[in]  attribute       Name of attribute
+ * @param[in]  name            Name of attribute
  * @param[in]  value           Value to be compared
  * @return     @c 0 on success, otherwise a negative error value
  * @pre                ctx_sched_job_context_prepare_attribute()
  */
-int ctx_sched_job_context_attribute_add_ne_str(ctx_sched_job_context_h job_context, const char* attribute, const char* value);
+int ctx_sched_job_context_attribute_add_ne_str(ctx_sched_job_context_h job_context, const char name, const char* value);
 
 /**
  * @brief      Adds a greater-than condition of a context attribute.
  * @param[in]  job_context     Context handle
- * @param[in]  attribute       Name of attribute
+ * @param[in]  name            Name of attribute
  * @param[in]  value           Value to be compared
  * @return     @c 0 on success, otherwise a negative error value
  * @pre                ctx_sched_job_context_prepare_attribute()
  */
-int ctx_sched_job_context_attribute_set_gt_int(ctx_sched_job_context_h job_context, const char* attribute, int value);
+int ctx_sched_job_context_attribute_set_gt_int(ctx_sched_job_context_h job_context, const char name, int value);
 
 /**
  * @brief      Adds a greater-than-or-equal-to condition of a context attribute.
  * @param[in]  job_context     Context handle
- * @param[in]  attribute       Name of attribute
+ * @param[in]  name            Name of attribute
  * @param[in]  value           Value to be compared
  * @return     @c 0 on success, otherwise a negative error value
  * @pre                ctx_sched_job_context_prepare_attribute()
  */
-int ctx_sched_job_context_attribute_set_ge_int(ctx_sched_job_context_h job_context, const char* attribute, int value);
+int ctx_sched_job_context_attribute_set_ge_int(ctx_sched_job_context_h job_context, const char name, int value);
 
 /**
  * @brief      Adds a less-than condition of a context attribute.
  * @param[in]  job_context     Context handle
- * @param[in]  attribute       Name of attribute
+ * @param[in]  name            Name of attribute
  * @param[in]  value           Value to be compared
  * @return     @c 0 on success, otherwise a negative error value
  * @pre                ctx_sched_job_context_prepare_attribute()
  */
-int ctx_sched_job_context_attribute_set_lt_int(ctx_sched_job_context_h job_context, const char* attribute, int value);
+int ctx_sched_job_context_attribute_set_lt_int(ctx_sched_job_context_h job_context, const char name, int value);
 
 /**
  * @brief      Adds a less-than-or-equal-to condition of a context attribute.
  * @param[in]  job_context     Context handle
- * @param[in]  attribute       Name of attribute
+ * @param[in]  name            Name of attribute
  * @param[in]  value           Value to be compared
  * @return     @c 0 on success, otherwise a negative error value
  * @pre                ctx_sched_job_context_prepare_attribute()
  */
-int ctx_sched_job_context_attribute_set_le_int(ctx_sched_job_context_h job_context, const char* attribute, int value);
+int ctx_sched_job_context_attribute_set_le_int(ctx_sched_job_context_h job_context, const char name, int value);
 
 /**
  * @brief      Releases the resources allocated for a job context.
@@ -455,6 +437,32 @@ int ctx_sched_job_context_attribute_set_le_int(ctx_sched_job_context_h job_conte
 int ctx_sched_job_context_destroy(ctx_sched_job_context_h job_context);
 
 
+/**
+ * @brief      Declares a custom context that can be used as a trigger or a requirement by other applications.
+ * @param[in]  scheduler       TBD
+ * @param[in]  uri                     TBD
+ * @return     @c 0 on success, otherwise a negative error value
+ */
+int ctx_sched_declare_context(ctx_sched_h scheduler, const char* uri);
+
+/**
+ * @brief      Retracts a custom context declared by the current application.
+ * @param[in]  scheduler       TBD
+ * @param[in]  uri                     TBD
+ * @return     @c 0 on success, otherwise a negative error value
+ */
+int ctx_sched_undeclare_context(ctx_sched_h scheduler, const char* uri);
+
+/**
+ * @brief      Publishes a custom context data corresponding to a URI declared using ctx_sched_declare_context().
+ * @param[in]  scheduler               TBD
+ * @param[in]  uri                             TBD
+ * @param[in]  json_payload    TBD
+ * @return     @c 0 on success, otherwise a negative error value
+ */
+int ctx_sched_publish_context_json(ctx_sched_h scheduler, const char* uri, const char* json_payload);
+
+
 // Logical-disjunction modifiers to support legacy Context-Trigger API.
 // NOT recommended to use.
 int ctx_sched_job_set_disjunction(ctx_sched_job_h job, bool disjunction);
index afbe03ba8b3e5a673fedab8c15dd9d300669f864..bc4d2456b44c2349171d8b817aecf3b2b8fc7ef0 100644 (file)
  * limitations under the License.
  */
 
+#include <ServiceProxy.h>
 #include <JobSchedulerTypesPrivate.h>
 #include <job_scheduler_internal.h>
+#include <JobInfo.h>
+#include <JobContext.h>
+#include <JobAction.h>
+#include <Attribute.h>
+
+#define ASSERT_ALLOC(PTR)      IF_FAIL_RETURN_TAG((PTR), E_NO_MEM, _E, E_STR_ALLOC)
+
+using namespace ctx;
 
 typedef struct _ctx_sched_s {
-       int dummy;
+       ServiceProxy proxy;     //FIXME
+       _ctx_sched_s() : proxy(CTX_JOB_SCHEDULER) {}
 } ctx_sched_s;
 
 typedef struct _ctx_sched_job_s {
-       int dummy;
+       int jobId;
+       bool started;
+       JobInfo* jobInfo;
+       _ctx_sched_job_s() : jobId(-1), started(false), jobInfo(NULL) {}
+       ~_ctx_sched_job_s() { delete jobInfo; }
 } ctx_sched_job_s;
 
 typedef struct _ctx_sched_job_context_s {
-       int dummy;
+       JobContext* jobContext;
+       _ctx_sched_job_context_s() : jobContext(NULL) {}
+       ~_ctx_sched_job_context_s() { delete jobContext; }
 } ctx_sched_job_context_s;
 
 
 EXPORT_API int ctx_sched_create(ctx_sched_h* scheduler)
 {
-       return E_SUPPORT;
+       ctx_sched_s* sched = new(std::nothrow) ctx_sched_s;
+       ASSERT_ALLOC(sched);
+
+       *scheduler = sched;
+       return E_NONE;
 }
 
 EXPORT_API int ctx_sched_destroy(ctx_sched_h scheduler)
 {
+       IF_FAIL_RETURN(scheduler, E_PARAM);
+       delete scheduler;
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_schedule(ctx_sched_h scheduler, ctx_sched_job_h job, int* job_id)
+{
+       int jid = -1;
+       int err = ctx_sched_add_job(scheduler, job, &jid);
+       IF_FAIL_RETURN(err == E_NONE, err);
+
+       err = ctx_sched_start_job(scheduler, jid);
+       if (err != E_NONE) {
+               ctx_sched_remove_job(scheduler, jid);
+               return err;
+       }
+
+       *job_id = jid;
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_cancel(ctx_sched_h scheduler, int job_id)
+{
+       ctx_sched_stop_job(scheduler, job_id);
+       return ctx_sched_remove_job(scheduler, job_id);
+}
+
+static bool __cancelJob(ctx_sched_h scheduler, ctx_sched_job_h job, void* user_data)
+{
+       int jid = -1;
+       ctx_sched_job_get_id(job, &jid);
+       ctx_sched_cancel(scheduler, jid);
+       ctx_sched_job_destroy(job);
+       return true;
+}
+
+EXPORT_API int ctx_sched_cancel_all(ctx_sched_h scheduler)
+{
+       return ctx_sched_foreach_job(scheduler, __cancelJob, NULL);
+}
+
+EXPORT_API int ctx_sched_add_job(ctx_sched_h scheduler, ctx_sched_job_h job, int* job_id)
+{
+       IF_FAIL_RETURN(scheduler && job && job_id, E_PARAM);
+
+       //TODO
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_start_job(ctx_sched_h scheduler, int job_id)
+{
+       IF_FAIL_RETURN(scheduler && job_id > 0, E_PARAM);
+
+       //TODO
        return E_SUPPORT;
 }
+
+EXPORT_API int ctx_sched_stop_job(ctx_sched_h scheduler, int job_id)
+{
+       IF_FAIL_RETURN(scheduler && job_id > 0, E_PARAM);
+
+       //TODO
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_remove_job(ctx_sched_h scheduler, int job_id)
+{
+       IF_FAIL_RETURN(scheduler && job_id > 0, E_PARAM);
+
+       //TODO
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_get_job(ctx_sched_h scheduler, int job_id, ctx_sched_job_h* job)
+{
+       IF_FAIL_RETURN(scheduler && job_id > 0 && job, E_PARAM);
+
+       //TODO
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_foreach_job(ctx_sched_h scheduler, ctx_sched_foreach_job_cb callback, void* user_data)
+{
+       IF_FAIL_RETURN(scheduler && callback, E_PARAM);
+
+       //TODO
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_set_stop_job_cb(ctx_sched_h scheduler, ctx_sched_stop_job_cb callback, void* user_data)
+{
+       IF_FAIL_RETURN(scheduler && callback, E_PARAM);
+
+       //TODO
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_job_create_periodic(unsigned int interval, time_t anchor, ctx_sched_job_h* job)
+{
+       IF_FAIL_RETURN(interval != 0 && job, E_PARAM);
+
+       ctx_sched_job_s* _job = new(std::nothrow) ctx_sched_job_s;
+       ASSERT_ALLOC(_job);
+
+       _job->jobInfo = new(std::nothrow) PeriodicJobInfo(interval, anchor);
+       if (!_job->jobInfo) {
+               _E_ALLOC;
+               delete _job;
+               return E_NO_MEM;
+       }
+
+       *job = _job;
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_create_on_demand(ctx_sched_job_h* job)
+{
+       IF_FAIL_RETURN(job, E_PARAM);
+
+       ctx_sched_job_s* _job = new(std::nothrow) ctx_sched_job_s;
+       ASSERT_ALLOC(_job);
+
+       _job->jobInfo = new(std::nothrow) OnDemandJobInfo();
+       if (!_job->jobInfo) {
+               _E_ALLOC;
+               delete _job;
+               return E_NO_MEM;
+       }
+
+       *job = _job;
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_destroy(ctx_sched_job_h job)
+{
+       IF_FAIL_RETURN(job, E_PARAM);
+
+       delete job;
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_add_trigger(ctx_sched_job_h job, ctx_sched_job_context_h trigger)
+{
+       IF_FAIL_RETURN(job && trigger, E_PARAM);
+       IF_FAIL_RETURN(job->jobInfo->getType() == JobInfo::Type::ON_DEMAND, E_PARAM);
+       IF_FAIL_RETURN(trigger->jobContext->getType() == JobContext::Type::TRIGGER, E_PARAM);
+
+       static_cast<OnDemandJobInfo*>(job->jobInfo)->addTrigger(static_cast<JobTrigger*>(trigger->jobContext));
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_add_requirement(ctx_sched_job_h job, ctx_sched_job_context_h requirement)
+{
+       IF_FAIL_RETURN(job && requirement, E_PARAM);
+       IF_FAIL_RETURN(requirement->jobContext->getType() == JobContext::Type::REQUIREMENT, E_PARAM);
+
+       job->jobInfo->addRequirement(static_cast<JobRequirement*>(requirement->jobContext));
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_set_requirement_timeout(ctx_sched_job_h job, unsigned int timeout)
+{
+       IF_FAIL_RETURN(job, E_PARAM);
+
+       job->jobInfo->setRequirementTimeout(timeout);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_set_persistent(ctx_sched_job_h job, bool persistent)
+{
+       IF_FAIL_RETURN(job, E_PARAM);
+
+       job->jobInfo->setPersistent(persistent);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_set_one_time(ctx_sched_job_h job, bool one_time)
+{
+       IF_FAIL_RETURN(job, E_PARAM);
+
+       job->jobInfo->setOneTime(one_time);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_set_app_control(ctx_sched_job_h job, bundle* app_control)
+{
+       IF_FAIL_RETURN(job, E_PARAM);
+
+       JobAction* action = new(std::nothrow) JobAppControl(app_control);
+       ASSERT_ALLOC(action);
+
+       job->jobInfo->setAction(action);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_set_dbus(ctx_sched_job_h job,
+               const char* bus_name, const char* object_path, const char* interface,
+               const char* method, GVariant* parameters)
+{
+       IF_FAIL_RETURN(job && bus_name && object_path && interface && method, E_PARAM);
+
+       JobAction* action = new(std::nothrow) JobDBusCall(bus_name, object_path, interface, method, parameters);
+       ASSERT_ALLOC(action);
+
+       job->jobInfo->setAction(action);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_set_user_data(ctx_sched_job_h job, const char* user_data)
+{
+       IF_FAIL_RETURN(job && user_data, E_PARAM);
+
+       job->jobInfo->setUserData(user_data);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_is_started(ctx_sched_job_h job, bool* started)
+{
+       IF_FAIL_RETURN(job && started, E_PARAM);
+
+       *started = job->started;
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_get_id(ctx_sched_job_h job, int* job_id)
+{
+       IF_FAIL_RETURN(job && job_id, E_PARAM);
+
+       *job_id = job->jobId;
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_get_user_data(ctx_sched_job_h job, const char** user_data)
+{
+       IF_FAIL_RETURN(job && user_data, E_PARAM);
+
+       *user_data = job->jobInfo->getUserData().c_str();
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_trigger_is_supported(const char* uri, bool* supported)
+{
+       IF_FAIL_RETURN(uri && supported, E_PARAM);
+
+       //TODO
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_trigger_create(const char* uri, ctx_sched_job_context_h* job_context)
+{
+       IF_FAIL_RETURN(uri && job_context, E_PARAM);
+
+       bool supported = false;
+       ctx_sched_job_trigger_is_supported(uri, &supported);
+       IF_FAIL_RETURN(supported, E_SUPPORT);
+
+       ctx_sched_job_context_s* jobCtxHandle = new(std::nothrow) ctx_sched_job_context_s();
+       ASSERT_ALLOC(jobCtxHandle);
+
+       jobCtxHandle->jobContext = new(std::nothrow) JobTrigger(uri);
+       if (!jobCtxHandle->jobContext) {
+               _E_ALLOC;
+               delete jobCtxHandle;
+               return E_NO_MEM;
+       }
+
+       *job_context = jobCtxHandle;
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_requirement_is_supported(const char* uri, bool* supported)
+{
+       IF_FAIL_RETURN(uri && supported, E_PARAM);
+
+       //TODO
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_job_requirement_create(const char* uri, bool optional, ctx_sched_job_context_h* job_context)
+{
+       IF_FAIL_RETURN(uri && job_context, E_PARAM);
+
+       bool supported = false;
+       ctx_sched_job_requirement_is_supported(uri, &supported);
+       IF_FAIL_RETURN(supported, E_SUPPORT);
+
+       ctx_sched_job_context_s* jobCtxHandle = new(std::nothrow) ctx_sched_job_context_s();
+       ASSERT_ALLOC(jobCtxHandle);
+
+       jobCtxHandle->jobContext = new(std::nothrow) JobRequirement(uri, optional);
+       if (!jobCtxHandle->jobContext) {
+               _E_ALLOC;
+               delete jobCtxHandle;
+               return E_NO_MEM;
+       }
+
+       *job_context = jobCtxHandle;
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_context_prepare_name_int(ctx_sched_job_context_h job_context, const char* name)
+{
+       IF_FAIL_RETURN(job_context && name, E_PARAM);
+
+       bool ret = job_context->jobContext->prepareAttributeInt(name);
+       return ret ? E_NONE : E_PARAM;
+}
+
+EXPORT_API int ctx_sched_job_context_prepare_name_str(ctx_sched_job_context_h job_context, const char* name)
+{
+       IF_FAIL_RETURN(job_context && name, E_PARAM);
+
+       bool ret = job_context->jobContext->prepareAttributeStr(name);
+       return ret ? E_NONE : E_PARAM;
+}
+
+EXPORT_API int ctx_sched_job_context_name_add_eq_int(ctx_sched_job_context_h job_context, const char* name, int value)
+{
+       IF_FAIL_RETURN(job_context && name, E_PARAM);
+
+       Attribute* attr = job_context->jobContext->getAttribute(name);
+       IF_FAIL_RETURN(attr, E_PARAM);
+       IF_FAIL_RETURN(attr->getType() == Attribute::Type::INTEGER, E_PARAM);
+
+       static_cast<IntegerAttribute*>(attr)->addTarget(value);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_context_name_add_eq_str(ctx_sched_job_context_h job_context, const char* name, const char* value)
+{
+       IF_FAIL_RETURN(job_context && name, E_PARAM);
+
+       Attribute* attr = job_context->jobContext->getAttribute(name);
+       IF_FAIL_RETURN(attr, E_PARAM);
+       IF_FAIL_RETURN(attr->getType() == Attribute::Type::STRING, E_PARAM);
+
+       static_cast<StringAttribute*>(attr)->addTarget(value);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_context_name_add_ne_int(ctx_sched_job_context_h job_context, const char* name, int value)
+{
+       IF_FAIL_RETURN(job_context && name, E_PARAM);
+
+       Attribute* attr = job_context->jobContext->getAttribute(name);
+       IF_FAIL_RETURN(attr, E_PARAM);
+       IF_FAIL_RETURN(attr->getType() == Attribute::Type::INTEGER, E_PARAM);
+
+       static_cast<IntegerAttribute*>(attr)->addNonTarget(value);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_context_name_add_ne_str(ctx_sched_job_context_h job_context, const char* name, const char* value)
+{
+       IF_FAIL_RETURN(job_context && name, E_PARAM);
+
+       Attribute* attr = job_context->jobContext->getAttribute(name);
+       IF_FAIL_RETURN(attr, E_PARAM);
+       IF_FAIL_RETURN(attr->getType() == Attribute::Type::STRING, E_PARAM);
+
+       static_cast<StringAttribute*>(attr)->addNonTarget(value);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_context_name_set_gt_int(ctx_sched_job_context_h job_context, const char* name, int value)
+{
+       IF_FAIL_RETURN(job_context && name, E_PARAM);
+
+       Attribute* attr = job_context->jobContext->getAttribute(name);
+       IF_FAIL_RETURN(attr, E_PARAM);
+       IF_FAIL_RETURN(attr->getType() == Attribute::Type::INTEGER, E_PARAM);
+
+       static_cast<IntegerAttribute*>(attr)->setOpenLowerBound(value);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_context_name_set_ge_int(ctx_sched_job_context_h job_context, const char* name, int value)
+{
+       IF_FAIL_RETURN(job_context && name, E_PARAM);
+
+       Attribute* attr = job_context->jobContext->getAttribute(name);
+       IF_FAIL_RETURN(attr, E_PARAM);
+       IF_FAIL_RETURN(attr->getType() == Attribute::Type::INTEGER, E_PARAM);
+
+       static_cast<IntegerAttribute*>(attr)->setClosedLowerBound(value);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_context_name_set_lt_int(ctx_sched_job_context_h job_context, const char* name, int value)
+{
+       IF_FAIL_RETURN(job_context && name, E_PARAM);
+
+       Attribute* attr = job_context->jobContext->getAttribute(name);
+       IF_FAIL_RETURN(attr, E_PARAM);
+       IF_FAIL_RETURN(attr->getType() == Attribute::Type::INTEGER, E_PARAM);
+
+       static_cast<IntegerAttribute*>(attr)->setOpenUpperBound(value);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_context_name_set_le_int(ctx_sched_job_context_h job_context, const char* name, int value)
+{
+       IF_FAIL_RETURN(job_context && name, E_PARAM);
+
+       Attribute* attr = job_context->jobContext->getAttribute(name);
+       IF_FAIL_RETURN(attr, E_PARAM);
+       IF_FAIL_RETURN(attr->getType() == Attribute::Type::INTEGER, E_PARAM);
+
+       static_cast<IntegerAttribute*>(attr)->setClosedUpperBound(value);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_context_destroy(ctx_sched_job_context_h job_context)
+{
+       IF_FAIL_RETURN(job_context, E_PARAM);
+
+       delete job_context;
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_declare_context(ctx_sched_h scheduler, const char* uri)
+{
+       IF_FAIL_RETURN(scheduler && uri, E_PARAM);
+       //TODO
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_undeclare_context(ctx_sched_h scheduler, const char* uri)
+{
+       IF_FAIL_RETURN(scheduler && uri, E_PARAM);
+       //TODO
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_publish_context_json(ctx_sched_h scheduler, const char* uri, const char* json_payload)
+{
+       IF_FAIL_RETURN(scheduler && uri && json_payload, E_PARAM);
+       //TODO
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_job_set_disjunction(ctx_sched_job_h job, bool disjunction)
+{
+       IF_FAIL_RETURN(job, E_PARAM);
+
+       job->jobInfo->setDisjunction(disjunction);
+       return E_NONE;
+}
+
+EXPORT_API int ctx_sched_job_context_set_disjunction(ctx_sched_job_context_h job_context, bool disjunction)
+{
+       IF_FAIL_RETURN(job_context, E_PARAM);
+
+       job_context->jobContext->setDisjunction(disjunction);
+       return E_NONE;
+}