From 90cd9a1048f844b7df3baeb7b537c6fa7717e2f7 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Fri, 22 Apr 2016 18:04:14 +0900 Subject: [PATCH] Split the .a file into .so files Each .so provides create() function, and contextd will the function for each so. Later, the create() will be updated to support on-demand loading of providers. Change-Id: Icc9f204941500c5e9d95f39644d4001fba36c76b Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 107 +----------------- context-provider.pc.in | 13 --- packaging/context-provider.spec | 17 +-- src/CMakeLists.txt | 24 ++++ src/activity/Activity.cpp | 2 +- src/activity/CMakeLists.txt | 19 ++++ .../activity/create.cpp | 31 +++-- src/app-stats/CMakeLists.txt | 23 ++++ src/app-stats/create.cpp | 38 +++++++ src/call/CMakeLists.txt | 20 ++++ .../call/create.cpp | 19 ++-- src/contacts/CMakeLists.txt | 19 ++++ src/contacts/create.cpp | 31 +++++ src/email/CMakeLists.txt | 19 ++++ .../email/create.cpp | 19 ++-- src/geofence/CMakeLists.txt | 19 ++++ src/geofence/create.cpp | 31 +++++ src/headphone/CMakeLists.txt | 20 ++++ src/headphone/create.cpp | 31 +++++ src/media-stats/CMakeLists.txt | 19 ++++ src/media-stats/create.cpp | 38 +++++++ src/message/CMakeLists.txt | 19 ++++ src/message/create.cpp | 31 +++++ src/my-place/CMakeLists.txt | 20 ++++ src/my-place/create.cpp | 33 ++++++ src/shared/BasicProvider.h | 2 +- src/shared/CMakeLists.txt | 19 ++++ src/shared/DbHandleBase.h | 2 +- src/shared/DeviceContextProvider.cpp | 91 --------------- src/shared/ProviderTypes.h | 9 ++ src/shared/StatisticsContextProvider.cpp | 70 ------------ src/shared/SystemInfo.cpp | 6 +- src/shared/Util.cpp | 2 +- .../{PlaceContextProvider.cpp => create.h} | 26 +---- src/social-stats/CMakeLists.txt | 19 ++++ src/social-stats/create.cpp | 34 ++++++ src/system/CMakeLists.txt | 22 ++++ src/system/create.cpp | 39 +++++++ src/time/CMakeLists.txt | 18 +++ src/time/create.cpp | 33 ++++++ src/wifi/CMakeLists.txt | 19 ++++ .../wifi/create.cpp | 19 ++-- 42 files changed, 734 insertions(+), 358 deletions(-) delete mode 100644 context-provider.pc.in create mode 100644 src/CMakeLists.txt create mode 100644 src/activity/CMakeLists.txt rename include/CustomContextProvider.h => src/activity/create.cpp (51%) create mode 100644 src/app-stats/CMakeLists.txt create mode 100644 src/app-stats/create.cpp create mode 100644 src/call/CMakeLists.txt rename include/PlaceContextProvider.h => src/call/create.cpp (60%) create mode 100644 src/contacts/CMakeLists.txt create mode 100644 src/contacts/create.cpp create mode 100644 src/email/CMakeLists.txt rename include/StatisticsContextProvider.h => src/email/create.cpp (61%) create mode 100644 src/geofence/CMakeLists.txt create mode 100644 src/geofence/create.cpp create mode 100644 src/headphone/CMakeLists.txt create mode 100644 src/headphone/create.cpp create mode 100644 src/media-stats/CMakeLists.txt create mode 100644 src/media-stats/create.cpp create mode 100644 src/message/CMakeLists.txt create mode 100644 src/message/create.cpp create mode 100644 src/my-place/CMakeLists.txt create mode 100644 src/my-place/create.cpp create mode 100644 src/shared/CMakeLists.txt delete mode 100644 src/shared/DeviceContextProvider.cpp delete mode 100644 src/shared/StatisticsContextProvider.cpp rename src/shared/{PlaceContextProvider.cpp => create.h} (64%) create mode 100644 src/social-stats/CMakeLists.txt create mode 100644 src/social-stats/create.cpp create mode 100644 src/system/CMakeLists.txt create mode 100644 src/system/create.cpp create mode 100644 src/time/CMakeLists.txt create mode 100644 src/time/create.cpp create mode 100644 src/wifi/CMakeLists.txt rename include/DeviceContextProvider.h => src/wifi/create.cpp (60%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f776afe..2865cb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,16 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(context-provider) INCLUDE(GNUInstallDirs) -SET(target "context-provider") -SET(compile_defs "LOG_TAG=\"CONTEXT\"") +SET(target_prefix "ctx-prvd") # Common Options INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src/shared ) -ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden) +ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections) +ADD_DEFINITIONS(-fvisibility=hidden) +ADD_DEFINITIONS(-DLOG_TAG="CONTEXT") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section") # Profiles @@ -21,102 +22,4 @@ IF("${PROFILE}" STREQUAL "wearable") ADD_DEFINITIONS("-D_WEARABLE_") ENDIF("${PROFILE}" STREQUAL "wearable") - -# Dependency & Source -SET(DEPS - libcontext-server - vconf - capi-system-info - capi-system-device - capi-system-runtime-info - capi-appfw-package-manager - capi-appfw-application - capi-appfw-app-manager - pkgmgr - pkgmgr-info - capi-media-sound-manager - capi-network-bluetooth - capi-network-wifi - motion -) - -FILE(GLOB SRCS - src/shared/*.cpp - src/time/*.cpp - src/activity/*.cpp - src/app-stats/*.cpp - src/headphone/*.cpp - src/system/*.cpp - src/wifi/*.cpp -) - -IF("${PROFILE}" STREQUAL "mobile") -SET(DEPS ${DEPS} - msg-service - contacts-service2 - tapi - capi-telephony - capi-messaging-email - capi-content-media-content - capi-location-manager - capi-geofence-manager -) - -FILE(GLOB SRCS ${SRCS} - src/call/*.cpp - src/contacts/*.cpp - src/email/*.cpp - src/geofence/*.cpp - src/media-stats/*.cpp - src/message/*.cpp - src/my-place/*.cpp - src/my-place/user_places/*.cpp - src/social-stats/*.cpp -) -ENDIF("${PROFILE}" STREQUAL "mobile") - - -# Build -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(DEPS REQUIRED ${DEPS}) - -FOREACH(flag ${DEPS_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -ADD_LIBRARY(${target} STATIC ${SRCS}) -TARGET_LINK_LIBRARIES(${target} ${DEPS_LDFLAGS}) -SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS}) -SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "${compile_defs}") -SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER}) -SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) - -# Package Config -FOREACH(item IN LISTS DEPS) - SET(deps_str "${deps_str} ${item}") -ENDFOREACH(item) - -SET(VERSION ${FULLVER}) -SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -SET(PC_NAME ${PROJECT_NAME}) -SET(PC_DESCRIPTION "Tizen Context Framework Context Provider") -SET(PC_INCLUDE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/context-service") -SET(PC_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") -SET(PC_CFLAGS "-I\${includedir}/context-service") -SET(PC_LDFLAGS "-l${target}") -SET(PC_REQUIRED "${deps_str}") - -CONFIGURE_FILE( - ${PROJECT_NAME}.pc.in - ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc - @ONLY -) - -# Installing -INSTALL( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/context-service/internal - FILES_MATCHING PATTERN "*.h" -) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +ADD_SUBDIRECTORY(src) diff --git a/context-provider.pc.in b/context-provider.pc.in deleted file mode 100644 index 378b991..0000000 --- a/context-provider.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -#Package Information for pkg-config - -prefix=@PREFIX@ -exec_prefix=@PREFIX@ -libdir=@PC_LIBDIR@ -includedir=@PC_INCLUDE@ - -Name: @PC_NAME@ -Description: @PC_DESCRIPTION@ -Version: @VERSION@ -Requires: @PC_REQUIRED@ -Libs: -L${libdir} @PC_LDFLAGS@ -Cflags: -I${includedir} diff --git a/packaging/context-provider.spec b/packaging/context-provider.spec index 598eb65..cd48f58 100644 --- a/packaging/context-provider.spec +++ b/packaging/context-provider.spec @@ -7,7 +7,6 @@ License: Apache-2.0 Source0: %{name}-%{version}.tar.gz %define BUILD_PROFILE %{?profile}%{!?profile:%{?tizen_profile_name}} -%define keepstatic 1 %if "%{?BUILD_PROFILE}" == "tv" ExcludeArch: %{arm} aarch64 %ix86 x86_64 @@ -90,17 +89,5 @@ cp LICENSE %{buildroot}/usr/share/license/%{name} %manifest packaging/%{name}.manifest %defattr(-,root,root,-) /usr/share/license/%{name} - -%package devel -Summary: Context Provider (Development) -Group: Service/Context -Requires: %{name} = %{version}-%{release} - -%description devel -Context Provider (Development) - -%files devel -%defattr(-,root,root,-) -%{_includedir}/context-service/internal/*.h -%{_libdir}/pkgconfig/%{name}.pc -%{_libdir}/*.a +%{_libdir}/*.so* +%{_libdir}/context/*.so* diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..2d1bb6a --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,24 @@ +SET(target_shared "${target_prefix}-shared") +SET(DEPS + libcontext-server +) + +ADD_SUBDIRECTORY(shared) +ADD_SUBDIRECTORY(activity) +ADD_SUBDIRECTORY(app-stats) +#ADD_SUBDIRECTORY(custom) +ADD_SUBDIRECTORY(headphone) +ADD_SUBDIRECTORY(system) +ADD_SUBDIRECTORY(time) +ADD_SUBDIRECTORY(wifi) + +IF("${PROFILE}" STREQUAL "mobile") +ADD_SUBDIRECTORY(call) +ADD_SUBDIRECTORY(contacts) +ADD_SUBDIRECTORY(email) +ADD_SUBDIRECTORY(geofence) +ADD_SUBDIRECTORY(media-stats) +ADD_SUBDIRECTORY(message) +ADD_SUBDIRECTORY(my-place) +ADD_SUBDIRECTORY(social-stats) +ENDIF("${PROFILE}" STREQUAL "mobile") diff --git a/src/activity/Activity.cpp b/src/activity/Activity.cpp index a71dbfb..017c061 100644 --- a/src/activity/Activity.cpp +++ b/src/activity/Activity.cpp @@ -19,7 +19,7 @@ using namespace ctx; -ActivityProvider::ActivityProvider(const char *subject, activity_type_e type) : +ActivityProvider::ActivityProvider(const char *subject, activity_type_e type) : BasicProvider(subject), __activityType(type), __activityHandle(NULL) diff --git a/src/activity/CMakeLists.txt b/src/activity/CMakeLists.txt new file mode 100644 index 0000000..29e8f5d --- /dev/null +++ b/src/activity/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-activity") + +SET(DEPS ${DEPS} + motion +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_ACTIVITY REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_ACTIVITY_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_ACTIVITY_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/include/CustomContextProvider.h b/src/activity/create.cpp similarity index 51% rename from include/CustomContextProvider.h rename to src/activity/create.cpp index b000fa5..5009ae3 100644 --- a/include/CustomContextProvider.h +++ b/src/activity/create.cpp @@ -14,24 +14,21 @@ * limitations under the License. */ -#ifndef _CONTEXT_CUSTOM_CONTEXT_PROVIDER_H_ -#define _CONTEXT_CUSTOM_CONTEXT_PROVIDER_H_ +#include +#include +#include "Activity.h" -namespace ctx { +using namespace ctx; - bool initCustomContextProvider(); +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ - namespace custom_context_provider { +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_ACTIVITY_STATIONARY, NULL); + registerProvider(SUBJ_ACTIVITY_WALKING, NULL); + registerProvider(SUBJ_ACTIVITY_RUNNING, NULL); + registerProvider(SUBJ_ACTIVITY_IN_VEHICLE, NULL); - int addItem(std::string subject, std::string name, ctx::Json tmpl, const char* owner, bool isInit = false); - int removeItem(std::string subject); - int publishData(std::string subject, ctx::Json fact); - - ContextProvider* create(void* data); - void destroy(void* data); - - } /* namespace custom_context_provider */ - -} /* namespace ctx */ - -#endif /* End of _CONTEXT_CUSTOM_CONTEXT_PROVIDER_H_ */ + return true; +} diff --git a/src/app-stats/CMakeLists.txt b/src/app-stats/CMakeLists.txt new file mode 100644 index 0000000..70b329e --- /dev/null +++ b/src/app-stats/CMakeLists.txt @@ -0,0 +1,23 @@ +SET(target "${target_prefix}-app-stats") + +SET(DEPS ${DEPS} + capi-appfw-package-manager + capi-appfw-application + capi-appfw-app-manager + pkgmgr + pkgmgr-info +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_APP_STATS REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_APP_STATS_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_APP_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/app-stats/create.cpp b/src/app-stats/create.cpp new file mode 100644 index 0000000..5002f9a --- /dev/null +++ b/src/app-stats/create.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "AppStatsProvider.h" +#include "AppStatsLogger.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(APP_SUBJ_LOGGER, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_RECENTLY_USED, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_FREQUENTLY_USED, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_RARELY_USED, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_PEAK_TIME, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_COMMON_SETTING, APP_HISTORY_PRIV); + registerProvider(APP_SUBJ_FREQUENCY, APP_HISTORY_PRIV); + + return true; +} diff --git a/src/call/CMakeLists.txt b/src/call/CMakeLists.txt new file mode 100644 index 0000000..8a60b79 --- /dev/null +++ b/src/call/CMakeLists.txt @@ -0,0 +1,20 @@ +SET(target "${target_prefix}-call") + +SET(DEPS ${DEPS} + tapi + capi-telephony +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_CALL REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_CALL_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_CALL_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/include/PlaceContextProvider.h b/src/call/create.cpp similarity index 60% rename from include/PlaceContextProvider.h rename to src/call/create.cpp index e7585b0..235db22 100644 --- a/include/PlaceContextProvider.h +++ b/src/call/create.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,13 +14,18 @@ * limitations under the License. */ -#ifndef _CONTEXT_PLACE_CONTEXT_PROVIDER_H_ -#define _CONTEXT_PLACE_CONTEXT_PROVIDER_H_ +#include +#include +#include "Call.h" -namespace ctx { +using namespace ctx; - bool initPlaceContextProvider(); +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ -} /* namespace ctx */ +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_CALL, PRIV_TELEPHONY); -#endif /* End of _CONTEXT_PLACE_CONTEXT_PROVIDER_H_ */ + return true; +} diff --git a/src/contacts/CMakeLists.txt b/src/contacts/CMakeLists.txt new file mode 100644 index 0000000..6773a23 --- /dev/null +++ b/src/contacts/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-contacts") + +SET(DEPS ${DEPS} + contacts-service2 +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_CONTACTS REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_CONTACTS_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_CONTACTS_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/contacts/create.cpp b/src/contacts/create.cpp new file mode 100644 index 0000000..b4b34b6 --- /dev/null +++ b/src/contacts/create.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "Contacts.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_CONTACTS, PRIV_CONTACT); + + return true; +} diff --git a/src/email/CMakeLists.txt b/src/email/CMakeLists.txt new file mode 100644 index 0000000..d6d6687 --- /dev/null +++ b/src/email/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-email") + +SET(DEPS ${DEPS} + capi-messaging-email +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_EMAIL REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_EMAIL_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_EMAIL_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/include/StatisticsContextProvider.h b/src/email/create.cpp similarity index 61% rename from include/StatisticsContextProvider.h rename to src/email/create.cpp index f356719..ac15430 100644 --- a/include/StatisticsContextProvider.h +++ b/src/email/create.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,13 +14,18 @@ * limitations under the License. */ -#ifndef _CONTEXT_STATISTICS_CONTEXT_PROVIDER_H_ -#define _CONTEXT_STATISTICS_CONTEXT_PROVIDER_H_ +#include +#include +#include "Email.h" -namespace ctx { +using namespace ctx; - bool initStatisticsContextProvider(); +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ -} /* namespace ctx */ +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_EMAIL, NULL); -#endif /* End of _CONTEXT_STATISTICS_CONTEXT_PROVIDER_H_ */ + return true; +} diff --git a/src/geofence/CMakeLists.txt b/src/geofence/CMakeLists.txt new file mode 100644 index 0000000..c52a0b0 --- /dev/null +++ b/src/geofence/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-geofence") + +SET(DEPS ${DEPS} + capi-geofence-manager +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_GEOFENCE REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_GEOFENCE_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_GEOFENCE_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/geofence/create.cpp b/src/geofence/create.cpp new file mode 100644 index 0000000..6f9ccbe --- /dev/null +++ b/src/geofence/create.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "PlaceGeofenceProvider.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_PLACE_GEOFENCE, PRIV_LOCATION); + + return true; +} diff --git a/src/headphone/CMakeLists.txt b/src/headphone/CMakeLists.txt new file mode 100644 index 0000000..1730405 --- /dev/null +++ b/src/headphone/CMakeLists.txt @@ -0,0 +1,20 @@ +SET(target "${target_prefix}-headphone") + +SET(DEPS ${DEPS} + capi-system-runtime-info + capi-network-bluetooth +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_HEADPHONE REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_HEADPHONE_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_HEADPHONE_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/headphone/create.cpp b/src/headphone/create.cpp new file mode 100644 index 0000000..79fa6a7 --- /dev/null +++ b/src/headphone/create.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "Headphone.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_HEADPHONE, NULL); + + return true; +} diff --git a/src/media-stats/CMakeLists.txt b/src/media-stats/CMakeLists.txt new file mode 100644 index 0000000..cb22916 --- /dev/null +++ b/src/media-stats/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-media-stats") + +SET(DEPS ${DEPS} + capi-content-media-content +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_MEDIA_STATS REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_MEDIA_STATS_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_MEDIA_STATS_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/media-stats/create.cpp b/src/media-stats/create.cpp new file mode 100644 index 0000000..48f4ee9 --- /dev/null +++ b/src/media-stats/create.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "MediaStatsProvider.h" +#include "MediaStatsLogger.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(MEDIA_SUBJ_LOGGER, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_MUSIC_FREQUENCY, MEDIA_HISTORY_PRIV); + registerProvider(MEDIA_SUBJ_VIDEO_FREQUENCY, MEDIA_HISTORY_PRIV); + + return true; +} diff --git a/src/message/CMakeLists.txt b/src/message/CMakeLists.txt new file mode 100644 index 0000000..0de59a0 --- /dev/null +++ b/src/message/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-message") + +SET(DEPS ${DEPS} + msg-service +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_MESSAGE REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_MESSAGE_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_MESSAGE_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/message/create.cpp b/src/message/create.cpp new file mode 100644 index 0000000..7588850 --- /dev/null +++ b/src/message/create.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "Message.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_MESSAGE, PRIV_MESSAGE); + + return true; +} diff --git a/src/my-place/CMakeLists.txt b/src/my-place/CMakeLists.txt new file mode 100644 index 0000000..5277817 --- /dev/null +++ b/src/my-place/CMakeLists.txt @@ -0,0 +1,20 @@ +SET(target "${target_prefix}-my-place") + +SET(DEPS ${DEPS} + capi-location-manager + capi-network-wifi +) + +FILE(GLOB_RECURSE SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_MYPLACE REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_MYPLACE_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_MYPLACE_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/my-place/create.cpp b/src/my-place/create.cpp new file mode 100644 index 0000000..91cdaf9 --- /dev/null +++ b/src/my-place/create.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "place_recognition.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + /* + registerProvider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); + */ + + return true; +} diff --git a/src/shared/BasicProvider.h b/src/shared/BasicProvider.h index 84b0838..069cc3a 100644 --- a/src/shared/BasicProvider.h +++ b/src/shared/BasicProvider.h @@ -24,7 +24,7 @@ namespace ctx { /* BasicProvider implements the very basic form of context providers, which has no controllable options, and does not set the requestResult parameter to reply to clients' requests immediately. */ - class BasicProvider : public ContextProvider { + class SO_EXPORT BasicProvider : public ContextProvider { public: int subscribe(Json option, Json *requestResult); int unsubscribe(Json option); diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt new file mode 100644 index 0000000..fc20fe4 --- /dev/null +++ b/src/shared/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(DEPS ${DEPS} + capi-system-info + capi-system-runtime-info + capi-media-sound-manager +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_SHARED REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_SHARED_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target_shared} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target_shared} ${PKG_SHARED_LDFLAGS}) + +INSTALL(TARGETS ${target_shared} DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/src/shared/DbHandleBase.h b/src/shared/DbHandleBase.h index 8949550..3404821 100644 --- a/src/shared/DbHandleBase.h +++ b/src/shared/DbHandleBase.h @@ -22,7 +22,7 @@ #include namespace ctx { - class StatsDbHandleBase : public IDatabaseListener { + class SO_EXPORT StatsDbHandleBase : public IDatabaseListener { protected: bool isTriggerItem; ContextProvider *reqProvider; diff --git a/src/shared/DeviceContextProvider.cpp b/src/shared/DeviceContextProvider.cpp deleted file mode 100644 index 1726c98..0000000 --- a/src/shared/DeviceContextProvider.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "../time/Alarm.h" -#include "../time/Time.h" -#include "../activity/Activity.h" -#include "../headphone/Headphone.h" -#include "../system/Battery.h" -#include "../system/Charger.h" -#include "../system/Gps.h" -#include "../system/Psmode.h" -#include "../system/Usb.h" -#include "../wifi/Wifi.h" - -#ifdef _MOBILE_ -#include "../call/Call.h" -#include "../contacts/Contacts.h" -#include "../email/Email.h" -#include "../message/Message.h" -#endif - -#define PRIV_NETWORK "network.get" -#define PRIV_TELEPHONY "telephony" -#define PRIV_MESSAGE "message.read" -#define PRIV_CONTACT "contact.read" - -template -void registerProvider(const char *subject, const char *privilege) -{ - Provider *provider = new(std::nothrow) Provider(); - IF_FAIL_VOID_TAG(provider, _E, "Memory allocation failed"); - - if (!provider->isSupported()) { - delete provider; - return; - } - - provider->registerProvider(privilege, provider); - provider->submitTriggerItem(); -} - -SO_EXPORT bool ctx::initDeviceContextProvider() -{ - registerProvider(SUBJ_STATE_ALARM, NULL); - registerProvider(SUBJ_STATE_TIME, NULL); - - registerProvider(SUBJ_STATE_WIFI, PRIV_NETWORK); - registerProvider(SUBJ_STATE_HEADPHONE, NULL); - - registerProvider(SUBJ_STATE_CHARGER, NULL); - registerProvider(SUBJ_STATE_GPS, NULL); - registerProvider(SUBJ_STATE_USB, NULL); - registerProvider(SUBJ_STATE_BATTERY, NULL); - registerProvider(SUBJ_STATE_PSMODE, NULL); - - registerProvider(SUBJ_ACTIVITY_STATIONARY, NULL); - registerProvider(SUBJ_ACTIVITY_WALKING, NULL); - registerProvider(SUBJ_ACTIVITY_RUNNING, NULL); - registerProvider(SUBJ_ACTIVITY_IN_VEHICLE, NULL); - -#ifdef _MOBILE_ - registerProvider(SUBJ_STATE_CALL, PRIV_TELEPHONY); - registerProvider(SUBJ_STATE_EMAIL, NULL); - registerProvider(SUBJ_STATE_MESSAGE, PRIV_MESSAGE); - registerProvider(SUBJ_STATE_CONTACTS, PRIV_CONTACT); - - /* Create context providers, which need to be initiated before being subscribed */ - /* - if (WifiStateProvider::isSupported()) - WifiStateProvider::create(NULL); - */ -#endif - - return true; -} diff --git a/src/shared/ProviderTypes.h b/src/shared/ProviderTypes.h index 03ddd38..f5d0bac 100644 --- a/src/shared/ProviderTypes.h +++ b/src/shared/ProviderTypes.h @@ -18,6 +18,15 @@ #define _CONTEXT_PROVIDER_TYPES_H_ +/* Privileges */ +#define PRIV_ALARM "alarm.set" +#define PRIV_NETWORK "network.get" +#define PRIV_TELEPHONY "telephony" +#define PRIV_MESSAGE "message.read" +#define PRIV_CONTACT "contact.read" +#define PRIV_LOCATION "location" + + /* FW-wide Data Logger Parameters */ #define LOG_RETENTION_PERIOD 7776000 /* 90 days in secs */ diff --git a/src/shared/StatisticsContextProvider.cpp b/src/shared/StatisticsContextProvider.cpp deleted file mode 100644 index d547b60..0000000 --- a/src/shared/StatisticsContextProvider.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "../app-stats/AppStatsProvider.h" -#include "../app-stats/AppStatsLogger.h" - -#ifdef _MOBILE_ -#include "../media-stats/MediaStatsProvider.h" -#include "../media-stats/MediaStatsLogger.h" -#include "../social-stats/SocialStatsProvider.h" -#include "../social-stats/SocialStatsLogger.h" -#endif - -template -void registerProvider(const char *subject, const char *privilege) -{ - Provider *provider = new(std::nothrow) Provider(); - IF_FAIL_VOID_TAG(provider, _E, "Memory allocation failed"); - - if (!provider->isSupported()) { - delete provider; - return; - } - - provider->registerProvider(privilege, provider); - provider->submitTriggerItem(); -} - -SO_EXPORT bool ctx::initStatisticsContextProvider() -{ - registerProvider(APP_SUBJ_LOGGER, APP_HISTORY_PRIV); - registerProvider(APP_SUBJ_RECENTLY_USED, APP_HISTORY_PRIV); - registerProvider(APP_SUBJ_FREQUENTLY_USED, APP_HISTORY_PRIV); - registerProvider(APP_SUBJ_RARELY_USED, APP_HISTORY_PRIV); - registerProvider(APP_SUBJ_PEAK_TIME, APP_HISTORY_PRIV); - registerProvider(APP_SUBJ_COMMON_SETTING, APP_HISTORY_PRIV); - registerProvider(APP_SUBJ_FREQUENCY, APP_HISTORY_PRIV); - -#ifdef _MOBILE_ - registerProvider(MEDIA_SUBJ_LOGGER, MEDIA_HISTORY_PRIV); - registerProvider(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV); - registerProvider(MEDIA_SUBJ_PEAK_TIME_FOR_VIDEO, MEDIA_HISTORY_PRIV); - registerProvider(MEDIA_SUBJ_COMMON_SETTING_FOR_MUSIC, MEDIA_HISTORY_PRIV); - registerProvider(MEDIA_SUBJ_COMMON_SETTING_FOR_VIDEO, MEDIA_HISTORY_PRIV); - registerProvider(MEDIA_SUBJ_MUSIC_FREQUENCY, MEDIA_HISTORY_PRIV); - registerProvider(MEDIA_SUBJ_VIDEO_FREQUENCY, MEDIA_HISTORY_PRIV); - - registerProvider(SOCIAL_SUBJ_LOGGER, SOCIAL_HISTORY_PRIV); - registerProvider(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV); - registerProvider(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV); -#endif - - return true; -} diff --git a/src/shared/SystemInfo.cpp b/src/shared/SystemInfo.cpp index 63731f7..72ef4fe 100644 --- a/src/shared/SystemInfo.cpp +++ b/src/shared/SystemInfo.cpp @@ -26,7 +26,7 @@ using namespace ctx; -bool system_info::getAudioJackState(int* state) +SO_EXPORT bool system_info::getAudioJackState(int* state) { int value = NOT_CONNECTED; int err = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &value); @@ -37,7 +37,7 @@ bool system_info::getAudioJackState(int* state) return true; } -bool system_info::getVolume(int* systemVolume, int* mediaVolume) +SO_EXPORT bool system_info::getVolume(int* systemVolume, int* mediaVolume) { int err; @@ -50,7 +50,7 @@ bool system_info::getVolume(int* systemVolume, int* mediaVolume) return true; } -bool system_info::getWifiBssid(std::string& bssid) +SO_EXPORT bool system_info::getWifiBssid(std::string& bssid) { #if 0 /* NOTE: This routine does not work, because the wifi API does not support multi-sessions in one process */ diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp index e25d0db..bc32a57 100644 --- a/src/shared/Util.cpp +++ b/src/shared/Util.cpp @@ -18,7 +18,7 @@ #include #include "Util.h" -bool ctx::util::getSystemInfoBool(const char * key) +SO_EXPORT bool ctx::util::getSystemInfoBool(const char * key) { bool supported = false; int ret = system_info_get_platform_bool(key, &supported); diff --git a/src/shared/PlaceContextProvider.cpp b/src/shared/create.h similarity index 64% rename from src/shared/PlaceContextProvider.cpp rename to src/shared/create.h index ec00515..2c57b7a 100644 --- a/src/shared/PlaceContextProvider.cpp +++ b/src/shared/create.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,16 +14,11 @@ * limitations under the License. */ +/* TODO: This is a temporary template implementation. + This will be removed soon. */ + #include #include -#include - -#ifdef _MOBILE_ -#include "../geofence/PlaceGeofenceProvider.h" -#include "../my-place/place_recognition.h" -#endif /* _MOBILE_ */ - -#define PRIV_LOCATION "location" template void registerProvider(const char *subject, const char *privilege) @@ -39,16 +34,3 @@ void registerProvider(const char *subject, const char *privilege) provider->registerProvider(privilege, provider); provider->submitTriggerItem(); } - -SO_EXPORT bool ctx::initPlaceContextProvider() -{ -#ifdef _MOBILE_ - registerProvider(SUBJ_PLACE_GEOFENCE, PRIV_LOCATION); - - /* - registerProvider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); - */ - -#endif /* _MOBILE_ */ - return true; -} diff --git a/src/social-stats/CMakeLists.txt b/src/social-stats/CMakeLists.txt new file mode 100644 index 0000000..004286e --- /dev/null +++ b/src/social-stats/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-social-stats") + +SET(DEPS ${DEPS} + contacts-service2 +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_SOCIAL_STATS REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_SOCIAL_STATS_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_SOCIAL_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/social-stats/create.cpp b/src/social-stats/create.cpp new file mode 100644 index 0000000..a498c28 --- /dev/null +++ b/src/social-stats/create.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "SocialStatsProvider.h" +#include "SocialStatsLogger.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SOCIAL_SUBJ_LOGGER, SOCIAL_HISTORY_PRIV); + registerProvider(SOCIAL_SUBJ_FREQUENCY, SOCIAL_HISTORY_PRIV); + registerProvider(SOCIAL_SUBJ_FREQ_ADDRESS, SOCIAL_HISTORY_PRIV); + + return true; +} diff --git a/src/system/CMakeLists.txt b/src/system/CMakeLists.txt new file mode 100644 index 0000000..a349974 --- /dev/null +++ b/src/system/CMakeLists.txt @@ -0,0 +1,22 @@ +SET(target "${target_prefix}-system") + +SET(DEPS ${DEPS} + vconf + capi-system-info + capi-system-device + capi-system-runtime-info +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_SYSTEM REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_SYSTEM_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_SYSTEM_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/system/create.cpp b/src/system/create.cpp new file mode 100644 index 0000000..7add7b5 --- /dev/null +++ b/src/system/create.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "Battery.h" +#include "Charger.h" +#include "Gps.h" +#include "Psmode.h" +#include "Usb.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_BATTERY, NULL); + registerProvider(SUBJ_STATE_CHARGER, NULL); + registerProvider(SUBJ_STATE_GPS, NULL); + registerProvider(SUBJ_STATE_PSMODE, NULL); + registerProvider(SUBJ_STATE_USB, NULL); + + return true; +} diff --git a/src/time/CMakeLists.txt b/src/time/CMakeLists.txt new file mode 100644 index 0000000..1ea12af --- /dev/null +++ b/src/time/CMakeLists.txt @@ -0,0 +1,18 @@ +SET(target "${target_prefix}-time") + +#SET(DEPS ${DEPS} +#) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_TIME REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_TIME_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_TIME_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/src/time/create.cpp b/src/time/create.cpp new file mode 100644 index 0000000..e0da510 --- /dev/null +++ b/src/time/create.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "Alarm.h" +#include "Time.h" + +using namespace ctx; + +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ + +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_ALARM, PRIV_ALARM); + registerProvider(SUBJ_STATE_TIME, NULL); + + return true; +} diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt new file mode 100644 index 0000000..10ca397 --- /dev/null +++ b/src/wifi/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(target "${target_prefix}-wifi") + +SET(DEPS ${DEPS} + capi-network-wifi +) + +FILE(GLOB SRCS *.cpp) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PKG_WIFI REQUIRED ${DEPS}) + +FOREACH(flag ${PKG_WIFI_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${target} ${PKG_WIFI_LDFLAGS} ${target_shared}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/context) diff --git a/include/DeviceContextProvider.h b/src/wifi/create.cpp similarity index 60% rename from include/DeviceContextProvider.h rename to src/wifi/create.cpp index 1e47323..cb8a87e 100644 --- a/include/DeviceContextProvider.h +++ b/src/wifi/create.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,13 +14,18 @@ * limitations under the License. */ -#ifndef _CONTEXT_DEVICE_CONTEXT_PROVIDER_H_ -#define _CONTEXT_DEVICE_CONTEXT_PROVIDER_H_ +#include +#include +#include "Wifi.h" -namespace ctx { +using namespace ctx; - bool initDeviceContextProvider(); +/* TODO: This function will be changed into the following form: + ContextProvider* create(const char *subject) */ -} /* namespace ctx */ +extern "C" SO_EXPORT bool create() +{ + registerProvider(SUBJ_STATE_WIFI, PRIV_NETWORK); -#endif /* End of _CONTEXT_DEVICE_CONTEXT_PROVIDER_H_ */ + return true; +} -- 2.34.1