From a79281f4dbb683a004cae5976218b7173d4e17d9 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Wed, 14 Jun 2017 20:43:19 +0900 Subject: [PATCH] Bug fixes: API function name typos & mis-implemented JobSchedulerService class Change-Id: I2a36762f3307200e72c8e88565c838a81f93a8c5 Signed-off-by: Mu-Woong Lee --- include/job_scheduler_internal.h | 24 ++++++++++++++---------- include/private/JobSchedulerService.h | 2 -- src/client-dummy/job_scheduler.cpp | 20 ++++++++++---------- src/client/job_scheduler.cpp | 26 ++++++++++++++++---------- src/server/JobSchedulerService.cpp | 4 ++-- 5 files changed, 42 insertions(+), 34 deletions(-) diff --git a/include/job_scheduler_internal.h b/include/job_scheduler_internal.h index 30c6007..5dbba00 100644 --- a/include/job_scheduler_internal.h +++ b/include/job_scheduler_internal.h @@ -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. diff --git a/include/private/JobSchedulerService.h b/include/private/JobSchedulerService.h index def2c70..247e667 100644 --- a/include/private/JobSchedulerService.h +++ b/include/private/JobSchedulerService.h @@ -43,8 +43,6 @@ namespace ctx { IMethodCallHandler* createMethodCallHandler(); - GDBusConnection* getConnection(); - private: IServiceRunner* __serviceRunner; }; diff --git a/src/client-dummy/job_scheduler.cpp b/src/client-dummy/job_scheduler.cpp index 7fc4cce..40f6a3b 100644 --- a/src/client-dummy/job_scheduler.cpp +++ b/src/client-dummy/job_scheduler.cpp @@ -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; } diff --git a/src/client/job_scheduler.cpp b/src/client/job_scheduler.cpp index 26c4685..7e6a1fe 100644 --- a/src/client/job_scheduler.cpp +++ b/src/client/job_scheduler.cpp @@ -281,6 +281,9 @@ EXPORT_API int ctx_sched_job_add_trigger(ctx_sched_job_h job, ctx_sched_job_cont static_cast(job->jobInfo)->addTrigger(static_cast(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(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); diff --git a/src/server/JobSchedulerService.cpp b/src/server/JobSchedulerService.cpp index 4e6d1c2..d59a623 100644 --- a/src/server/JobSchedulerService.cpp +++ b/src/server/JobSchedulerService.cpp @@ -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() -- 2.7.4