Bug fixes: API function name typos & mis-implemented JobSchedulerService class 84/134084/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 14 Jun 2017 11:43:19 +0000 (20:43 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 14 Jun 2017 11:43:19 +0000 (20:43 +0900)
Change-Id: I2a36762f3307200e72c8e88565c838a81f93a8c5
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
include/job_scheduler_internal.h
include/private/JobSchedulerService.h
src/client-dummy/job_scheduler.cpp
src/client/job_scheduler.cpp
src/server/JobSchedulerService.cpp

index 30c6007bae7f256a85f5a34f85a4ebf11db57d16..5dbba00c4f7137d61adc739bb4f972148a06e3bd 100644 (file)
@@ -200,6 +200,8 @@ int ctx_sched_job_destroy(ctx_sched_job_h job);
 
 /**
  * @brief      Adds a trigger context to a job.
+ * @remarks    This function consumes the given @c trigger.
+ *                     Using the @c trigger after calling this function leads to undefined behavior.
  * @param[in]  job                     Job handle
  * @param[in]  trigger         Trigger context
  * @return     @c 0 on success, otherwise a negative error value
@@ -208,6 +210,8 @@ int ctx_sched_job_add_trigger(ctx_sched_job_h job, ctx_sched_job_context_h trigg
 
 /**
  * @brief      Adds a requirement context to a job.
+ * @remarks    This function consumes the given @c requirement.
+ *                     Using the @c requirement after calling this function leads to undefined behavior.
  * @param[in]  job                     Job handle
  * @param[in]  requirement     Requirement context
  * @return     @c 0 on success, otherwise a negative error value
@@ -347,7 +351,7 @@ int ctx_sched_job_requirement_create(const char* uri, bool optional, ctx_sched_j
  * @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 name);
+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.
@@ -355,7 +359,7 @@ int ctx_sched_job_context_prepare_attribute_int(ctx_sched_job_context_h job_cont
  * @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 name);
+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.
@@ -365,7 +369,7 @@ int ctx_sched_job_context_prepare_attribute_str(ctx_sched_job_context_h job_cont
  * @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 name, 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.
@@ -375,7 +379,7 @@ int ctx_sched_job_context_attribute_add_eq_int(ctx_sched_job_context_h job_conte
  * @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 name, 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.
@@ -385,7 +389,7 @@ int ctx_sched_job_context_attribute_add_eq_str(ctx_sched_job_context_h job_conte
  * @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 name, 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.
@@ -395,7 +399,7 @@ int ctx_sched_job_context_attribute_add_ne_int(ctx_sched_job_context_h job_conte
  * @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 name, 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.
@@ -405,7 +409,7 @@ int ctx_sched_job_context_attribute_add_ne_str(ctx_sched_job_context_h job_conte
  * @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 name, 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.
@@ -415,7 +419,7 @@ int ctx_sched_job_context_attribute_set_gt_int(ctx_sched_job_context_h job_conte
  * @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 name, 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.
@@ -425,7 +429,7 @@ int ctx_sched_job_context_attribute_set_ge_int(ctx_sched_job_context_h job_conte
  * @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 name, 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.
@@ -435,7 +439,7 @@ int ctx_sched_job_context_attribute_set_lt_int(ctx_sched_job_context_h job_conte
  * @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 name, 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.
index def2c705ade7328cfda072e35120aa95c4a2175b..247e66731959bf4d753834d27e77ea7a90c4c5af 100644 (file)
@@ -43,8 +43,6 @@ namespace ctx {
 
                IMethodCallHandler* createMethodCallHandler();
 
-               GDBusConnection* getConnection();
-
        private:
                IServiceRunner* __serviceRunner;
        };
index 7fc4ccec55e7ec6e0d1d8d5452ddfc4c62d95e43..40f6a3b21a2dc6714bf0cd2f5cf6369bfa0f315a 100644 (file)
@@ -181,52 +181,52 @@ EXPORT_API int ctx_sched_job_requirement_create(const char* uri, bool optional,
        return E_SUPPORT;
 }
 
-EXPORT_API int ctx_sched_job_context_prepare_name_int(ctx_sched_job_context_h job_context, const char* name)
+EXPORT_API int ctx_sched_job_context_prepare_attribute_int(ctx_sched_job_context_h job_context, const char* name)
 {
        return E_SUPPORT;
 }
 
-EXPORT_API int ctx_sched_job_context_prepare_name_str(ctx_sched_job_context_h job_context, const char* name)
+EXPORT_API int ctx_sched_job_context_prepare_attribute_str(ctx_sched_job_context_h job_context, const char* name)
 {
        return E_SUPPORT;
 }
 
-EXPORT_API int ctx_sched_job_context_name_add_eq_int(ctx_sched_job_context_h job_context, const char* name, int value)
+EXPORT_API int ctx_sched_job_context_attribute_add_eq_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        return E_SUPPORT;
 }
 
-EXPORT_API int ctx_sched_job_context_name_add_eq_str(ctx_sched_job_context_h job_context, const char* name, const char* value)
+EXPORT_API int ctx_sched_job_context_attribute_add_eq_str(ctx_sched_job_context_h job_context, const char* name, const char* value)
 {
        return E_SUPPORT;
 }
 
-EXPORT_API int ctx_sched_job_context_name_add_ne_int(ctx_sched_job_context_h job_context, const char* name, int value)
+EXPORT_API int ctx_sched_job_context_attribute_add_ne_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        return E_SUPPORT;
 }
 
-EXPORT_API int ctx_sched_job_context_name_add_ne_str(ctx_sched_job_context_h job_context, const char* name, const char* value)
+EXPORT_API int ctx_sched_job_context_attribute_add_ne_str(ctx_sched_job_context_h job_context, const char* name, const char* value)
 {
        return E_SUPPORT;
 }
 
-EXPORT_API int ctx_sched_job_context_name_set_gt_int(ctx_sched_job_context_h job_context, const char* name, int value)
+EXPORT_API int ctx_sched_job_context_attribute_set_gt_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        return E_SUPPORT;
 }
 
-EXPORT_API int ctx_sched_job_context_name_set_ge_int(ctx_sched_job_context_h job_context, const char* name, int value)
+EXPORT_API int ctx_sched_job_context_attribute_set_ge_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        return E_SUPPORT;
 }
 
-EXPORT_API int ctx_sched_job_context_name_set_lt_int(ctx_sched_job_context_h job_context, const char* name, int value)
+EXPORT_API int ctx_sched_job_context_attribute_set_lt_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        return E_SUPPORT;
 }
 
-EXPORT_API int ctx_sched_job_context_name_set_le_int(ctx_sched_job_context_h job_context, const char* name, int value)
+EXPORT_API int ctx_sched_job_context_attribute_set_le_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        return E_SUPPORT;
 }
index 26c468579bff0a0f17f1a8813dd72dcdfe5826f8..7e6a1fefccaf0d5535467aedf82f44b531428f66 100644 (file)
@@ -281,6 +281,9 @@ EXPORT_API int ctx_sched_job_add_trigger(ctx_sched_job_h job, ctx_sched_job_cont
 
        static_cast<OnDemandJobInfo*>(job->jobInfo)->addTrigger(static_cast<JobTrigger*>(trigger->jobContext));
 
+       trigger->jobContext = NULL;
+       delete trigger;
+
        return E_NONE;
 }
 
@@ -291,6 +294,9 @@ EXPORT_API int ctx_sched_job_add_requirement(ctx_sched_job_h job, ctx_sched_job_
 
        job->jobInfo->addRequirement(static_cast<JobRequirement*>(requirement->jobContext));
 
+       requirement->jobContext = NULL;
+       delete requirement;
+
        return E_NONE;
 }
 
@@ -447,7 +453,7 @@ EXPORT_API int ctx_sched_job_requirement_create(const char* uri, bool optional,
        return E_NONE;
 }
 
-EXPORT_API int ctx_sched_job_context_prepare_name_int(ctx_sched_job_context_h job_context, const char* name)
+EXPORT_API int ctx_sched_job_context_prepare_attribute_int(ctx_sched_job_context_h job_context, const char* name)
 {
        IF_FAIL_RETURN(job_context && name, E_PARAM);
 
@@ -456,7 +462,7 @@ EXPORT_API int ctx_sched_job_context_prepare_name_int(ctx_sched_job_context_h jo
        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)
+EXPORT_API int ctx_sched_job_context_prepare_attribute_str(ctx_sched_job_context_h job_context, const char* name)
 {
        IF_FAIL_RETURN(job_context && name, E_PARAM);
 
@@ -465,7 +471,7 @@ EXPORT_API int ctx_sched_job_context_prepare_name_str(ctx_sched_job_context_h jo
        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)
+EXPORT_API int ctx_sched_job_context_attribute_add_eq_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        IF_FAIL_RETURN(job_context && name, E_PARAM);
 
@@ -478,7 +484,7 @@ EXPORT_API int ctx_sched_job_context_name_add_eq_int(ctx_sched_job_context_h job
        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)
+EXPORT_API int ctx_sched_job_context_attribute_add_eq_str(ctx_sched_job_context_h job_context, const char* name, const char* value)
 {
        IF_FAIL_RETURN(job_context && name, E_PARAM);
 
@@ -491,7 +497,7 @@ EXPORT_API int ctx_sched_job_context_name_add_eq_str(ctx_sched_job_context_h job
        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)
+EXPORT_API int ctx_sched_job_context_attribute_add_ne_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        IF_FAIL_RETURN(job_context && name, E_PARAM);
 
@@ -504,7 +510,7 @@ EXPORT_API int ctx_sched_job_context_name_add_ne_int(ctx_sched_job_context_h job
        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)
+EXPORT_API int ctx_sched_job_context_attribute_add_ne_str(ctx_sched_job_context_h job_context, const char* name, const char* value)
 {
        IF_FAIL_RETURN(job_context && name, E_PARAM);
 
@@ -517,7 +523,7 @@ EXPORT_API int ctx_sched_job_context_name_add_ne_str(ctx_sched_job_context_h job
        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)
+EXPORT_API int ctx_sched_job_context_attribute_set_gt_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        IF_FAIL_RETURN(job_context && name, E_PARAM);
 
@@ -530,7 +536,7 @@ EXPORT_API int ctx_sched_job_context_name_set_gt_int(ctx_sched_job_context_h job
        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)
+EXPORT_API int ctx_sched_job_context_attribute_set_ge_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        IF_FAIL_RETURN(job_context && name, E_PARAM);
 
@@ -543,7 +549,7 @@ EXPORT_API int ctx_sched_job_context_name_set_ge_int(ctx_sched_job_context_h job
        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)
+EXPORT_API int ctx_sched_job_context_attribute_set_lt_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        IF_FAIL_RETURN(job_context && name, E_PARAM);
 
@@ -556,7 +562,7 @@ EXPORT_API int ctx_sched_job_context_name_set_lt_int(ctx_sched_job_context_h job
        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)
+EXPORT_API int ctx_sched_job_context_attribute_set_le_int(ctx_sched_job_context_h job_context, const char* name, int value)
 {
        IF_FAIL_RETURN(job_context && name, E_PARAM);
 
index 4e6d1c292f3d102045beed8f1ebaa42c1223d186..d59a623f6f774a70a8f7cbe37d730680b3e3a6e8 100644 (file)
@@ -40,12 +40,12 @@ bool JobSchedulerService::isUserService()
 
 const char* JobSchedulerService::getServiceName()
 {
-       return NULL;
+       return CTX_JOB_SCHEDULER;
 }
 
 const char* JobSchedulerService::getMethodSpecs()
 {
-       return NULL;
+       return CTX_JOB_SCHEDULER_SPEC;
 }
 
 bool JobSchedulerService::prepare()