Declare job-scheduler internal C API 92/124092/5
authorMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 10 Apr 2017 07:30:34 +0000 (16:30 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 12 Apr 2017 11:26:34 +0000 (20:26 +0900)
Change-Id: Iecc59de9cca833bdb9f368868812087db1585d78
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
CMakeLists.txt
include/job_scheduler_internal.h
include/job_scheduler_types_internal.h
packaging/context-job-scheduler.spec
src/client-dummy/CMakeLists.txt
src/client-dummy/job_scheduler.cpp
src/client/CMakeLists.txt
src/client/job_scheduler.cpp
src/server-dummy/CMakeLists.txt
src/server/CMakeLists.txt

index 933c3e3..3fba89b 100644 (file)
@@ -8,6 +8,8 @@ SET(INCDIR "${CMAKE_INSTALL_INCLUDEDIR}/context-service")
 INCLUDE_DIRECTORIES(
        ${CMAKE_INSTALL_PREFIX}/${INCDIR}/private
        ${CMAKE_SOURCE_DIR}/src/shared
+       ${CMAKE_SOURCE_DIR}/include
+       ${CMAKE_SOURCE_DIR}/include/private
 )
 
 ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden)
index ed0dda1..8ae0f4e 100644 (file)
 #ifndef __CAPI_CONTEXT_JOB_SCHEDULER_INTERNAL_H__
 #define __CAPI_CONTEXT_JOB_SCHEDULER_INTERNAL_H__
 
+#include <glib.h>
 #include <tizen.h>
+#include <bundle.h>
+#include <app_control.h>
 #include <job_scheduler_types_internal.h>
 
 #ifdef __cplusplus
@@ -25,7 +28,124 @@ extern "C"
 {
 #endif
 
-int ctx_job_scheduler_test();
+typedef struct _ctx_sched_s* ctx_sched_h;
+
+typedef struct _ctx_sched_job_s* ctx_sched_job_h;
+
+typedef struct _ctx_sched_job_context_s* ctx_sched_job_context_h;
+
+
+typedef bool (*ctx_sched_foreach_job_cb)(ctx_sched_h scheduler, ctx_sched_job_h job, void* user_data);
+
+typedef bool (*ctx_sched_stop_job_cb)(ctx_sched_h scheduler, ctx_sched_job_h job, void* user_data);
+
+
+int ctx_sched_create(ctx_sched_h* scheduler);
+
+int ctx_sched_destroy(ctx_sched_h scheduler);
+
+
+int ctx_sched_schedule(ctx_sched_h scheduler, ctx_sched_job_h job, int* job_id);
+
+int ctx_sched_cancel(ctx_sched_h scheduler, int job_id);
+
+int ctx_sched_cancel_all(ctx_sched_h scheduler);
+
+
+int ctx_sched_add_job(ctx_sched_h scheduler, ctx_sched_job_h job, int* job_id);
+
+int ctx_sched_start_job(ctx_sched_h scheduler, int job_id);
+
+int ctx_sched_stop_job(ctx_sched_h scheduler, int job_id);
+
+int ctx_sched_remove_job(ctx_sched_h scheduler, int job_id);
+
+
+int ctx_sched_get_job(ctx_sched_h scheduler, int job_id, ctx_sched_job_h* job);
+
+int ctx_sched_foreach_job(ctx_sched_h scheduler, ctx_sched_foreach_job_cb callback, void* user_data);
+
+
+int ctx_sched_set_stop_job_cb(ctx_sched_h scheduler, ctx_sched_stop_job_cb callback, void* user_data);
+
+
+int ctx_sched_declare_context(ctx_sched_h scheduler, const char* uri);
+
+int ctx_sched_undeclare_context(ctx_sched_h scheduler, const char* uri);
+
+int ctx_sched_publish_context_json(ctx_sched_h scheduler, const char* uri, const char* json_payload);
+
+
+int ctx_sched_job_create_periodic(unsigned int interval, time_t anchor, ctx_sched_job_h* job);
+
+int ctx_sched_job_create_on_demand(ctx_sched_job_h* job);
+
+int ctx_sched_job_destroy(ctx_sched_job_h job);
+
+
+int ctx_sched_job_add_trigger(ctx_sched_job_h job, ctx_sched_job_context_h trigger);
+
+int ctx_sched_job_add_requirement(ctx_sched_job_h job, ctx_sched_job_context_h requirement);
+
+int ctx_sched_job_set_requirement_timeout(ctx_sched_job_h job, unsigned int timeout);
+
+int ctx_sched_job_set_persistent(ctx_sched_job_h job, bool persistent);
+
+int ctx_sched_job_set_one_time(ctx_sched_job_h job, bool one_time);
+
+int ctx_sched_job_set_app_control(ctx_sched_job_h job, app_control_h app_control);
+
+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);
+
+int ctx_sched_job_set_bundle(ctx_sched_job_h job, bundle* user_bundle);
+
+
+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);
+
+int ctx_sched_job_get_bundle(ctx_sched_job_h job, bundle** user_bundle);
+
+
+int ctx_sched_job_trigger_is_supported(const char* uri, bool* supported);
+
+int ctx_sched_job_trigger_create(const char* uri, ctx_sched_job_context_h* job_context);
+
+int ctx_sched_job_requirement_is_supported(const char* uri, bool* supported);
+
+int ctx_sched_job_requirement_create(const char* uri, bool optional, ctx_sched_job_context_h* job_context);
+
+int ctx_sched_job_context_prepare_attribute(ctx_sched_job_context_h job_context, const char* 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_str(ctx_sched_job_context_h job_context, const char* attribute, const char* value);
+
+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_str(ctx_sched_job_context_h job_context, const char* attribute, const char* value);
+
+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_ge_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* attribute, int value);
+
+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_destroy(ctx_sched_job_context_h job_context);
+
+
+// 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);
+
+int ctx_sched_job_context_set_disjunction(ctx_sched_job_context_h job_context, bool disjunction);
+
+int ctx_sched_job_context_attribute_set_disjunction(ctx_sched_job_context_h job_context, const char* attribute, bool disjunction);
+
 
 #ifdef __cplusplus
 }
index 5bcbb83..c7cce3f 100644 (file)
 #define __CAPI_CONTEXT_JOB_SCHEDULER_TYPES_INTERNAL_H__
 
 
+#define CTX_SCHED_URI_PREFIX           "http://tizen.org/context/"
+
+#define CTX_SCHED_URI_BATTERY          CTX_SCHED_URI_PREFIX "state/battery"
+#define CTX_SCHED_URI_CHARGER          CTX_SCHED_URI_PREFIX "state/charger"
+#define CTX_SCHED_URI_GPS                      CTX_SCHED_URI_PREFIX "state/gps"
+#define CTX_SCHED_URI_NPS                      CTX_SCHED_URI_PREFIX "state/nps"
+#define CTX_SCHED_URI_EARJACK          CTX_SCHED_URI_PREFIX "state/earjack"
+#define CTX_SCHED_URI_USB                      CTX_SCHED_URI_PREFIX "state/usb"
+#define CTX_SCHED_URI_WIFI                     CTX_SCHED_URI_PREFIX "state/wifi"
+#define CTX_SCHED_URI_DISPLAY          CTX_SCHED_URI_PREFIX "state/display"
+#define CTX_SCHED_URI_POWERSAVE                CTX_SCHED_URI_PREFIX "state/powersave"
+
+#define CTX_SCHED_URI_STATIONARY       CTX_SCHED_URI_PREFIX "event/stationary"
+#define CTX_SCHED_URI_WALKING          CTX_SCHED_URI_PREFIX "event/walking"
+#define CTX_SCHED_URI_RUNNING          CTX_SCHED_URI_PREFIX "event/running"
+#define CTX_SCHED_URI_IN_VEHICLE       CTX_SCHED_URI_PREFIX "event/in_vehicle"
+#define CTX_SCHED_URI_GEOFENCE         CTX_SCHED_URI_PREFIX "event/geofence"
+
+#define CTX_SCHED_URI_CONTACTS_DB      CTX_SCHED_URI_PREFIX "event/contacts_db"
+#define CTX_SCHED_URI_CALENDAR_DB      CTX_SCHED_URI_PREFIX "event/calendar_db"
+#define CTX_SCHED_URI_PLACE_DB         CTX_SCHED_URI_PREFIX "event/place_db"
+
+
 #endif
index ebf6154..042b24e 100644 (file)
@@ -10,7 +10,10 @@ BuildRequires: cmake
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(bundle)
 BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(capi-appfw-application)
+
 BuildRequires: pkgconfig(context-common-server)
 BuildRequires: pkgconfig(context-common-client)
 
index eb5a5eb..294d53b 100644 (file)
@@ -1,8 +1,6 @@
 SET(target "${PROJECT_NAME}-client")
 
-SET(DEPS "${DEPS} context-common-client")
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+SET(DEPS "${DEPS} bundle capi-appfw-application context-common-client")
 
 FILE(GLOB_RECURSE SRCS *.cpp)
 MESSAGE("Sources: ${SRCS}")
index 8acd560..afbe03b 100644 (file)
 #include <JobSchedulerTypesPrivate.h>
 #include <job_scheduler_internal.h>
 
-/* TODO: Remove this test code */
-EXPORT_API int ctx_job_scheduler_test()
+typedef struct _ctx_sched_s {
+       int dummy;
+} ctx_sched_s;
+
+typedef struct _ctx_sched_job_s {
+       int dummy;
+} ctx_sched_job_s;
+
+typedef struct _ctx_sched_job_context_s {
+       int dummy;
+} ctx_sched_job_context_s;
+
+
+EXPORT_API int ctx_sched_create(ctx_sched_h* scheduler)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_destroy(ctx_sched_h scheduler)
 {
        return E_SUPPORT;
 }
index cce6a58..82b3aff 100644 (file)
@@ -1,8 +1,6 @@
 SET(target "${PROJECT_NAME}-client-genuine")
 
-SET(DEPS "${DEPS} context-common-client")
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+SET(DEPS "${DEPS} bundle capi-appfw-application context-common-client")
 
 FILE(GLOB_RECURSE SRCS *.cpp ../shared/*.cpp)
 MESSAGE("Sources: ${SRCS}")
index 8acd560..afbe03b 100644 (file)
 #include <JobSchedulerTypesPrivate.h>
 #include <job_scheduler_internal.h>
 
-/* TODO: Remove this test code */
-EXPORT_API int ctx_job_scheduler_test()
+typedef struct _ctx_sched_s {
+       int dummy;
+} ctx_sched_s;
+
+typedef struct _ctx_sched_job_s {
+       int dummy;
+} ctx_sched_job_s;
+
+typedef struct _ctx_sched_job_context_s {
+       int dummy;
+} ctx_sched_job_context_s;
+
+
+EXPORT_API int ctx_sched_create(ctx_sched_h* scheduler)
+{
+       return E_SUPPORT;
+}
+
+EXPORT_API int ctx_sched_destroy(ctx_sched_h scheduler)
 {
        return E_SUPPORT;
 }
index 3934aa8..8913003 100644 (file)
@@ -2,8 +2,6 @@ SET(target "${PROJECT_NAME}-server")
 
 SET(DEPS "${DEPS} context-common-server")
 
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/private)
-
 FILE(GLOB_RECURSE SRCS *.cpp)
 MESSAGE("Sources: ${SRCS}")
 
index 782313c..64a741f 100644 (file)
@@ -2,9 +2,6 @@ SET(target "${PROJECT_NAME}-server-genuine")
 
 SET(DEPS "${DEPS} context-common-server")
 
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/private)
-
 FILE(GLOB_RECURSE SRCS *.cpp ../shared/*.cpp)
 MESSAGE("Sources: ${SRCS}")