From a0143cea85671ffb6b0550f67f4bce12a1ad7c5e Mon Sep 17 00:00:00 2001 From: Sungbae Yoo Date: Wed, 3 Aug 2016 15:10:27 +0900 Subject: [PATCH 01/16] Move krate service and library from device-policy-manager git Change-Id: I41078b9ba27da5947fa2d4b30b7edf94c540bf69 Signed-off-by: Jaemin Ryu Signed-off-by: Sungbae Yoo --- CMakeLists.txt | 2 +- krate.manifest | 3 + lib/CMakeLists.txt | 59 +++ lib/app-proxy.cpp | 105 ++++ lib/client.cpp | 80 +++ lib/client.h | 59 +++ lib/context.h | 24 + lib/krate.pc.in | 12 + lib/krate/app-info-internal.h | 115 +++++ lib/krate/app-proxy.cpp | 258 ++++++++++ lib/krate/app-proxy.h | 235 +++++++++ lib/krate/debug.h | 26 + lib/krate/krate.cpp | 156 ++++++ lib/krate/krate.h | 309 ++++++++++++ lib/krate/package-info-internal.h | 106 ++++ lib/krate/package-proxy.cpp | 316 ++++++++++++ lib/krate/package-proxy.h | 254 ++++++++++ lib/manager.cpp | 94 ++++ lib/package-proxy.cpp | 63 +++ module/CMakeLists.txt | 19 +- module/krate.cpp | 4 +- packaging/krate.spec | 65 +-- rmi/app-proxy.h | 90 ++++ rmi/manager.h | 50 ++ rmi/package-proxy.h | 74 +++ server/CMakeLists.txt | 51 +- server/app-bundle.cpp | 51 ++ server/app-bundle.h | 55 ++ server/app-proxy.cpp | 255 ++++++++++ server/context.h | 24 + server/launchpad.cpp | 67 +++ server/launchpad.h | 40 ++ server/main.cpp | 50 ++ server/manager.cpp | 701 ++++++++++++++++++++++++++ server/package-proxy.cpp | 126 +++++ server/packman.cpp | 427 ++++++++++++++++ server/packman.h | 115 +++++ server/server.cpp | 102 ++++ server/server.h | 78 +++ server/systemd/krate.service.in | 7 +- tools/CMakeLists.txt | 4 +- tools/apps/kaskit/src/main.c | 8 +- tools/apps/kaskit/src/widget.c | 2 +- tools/apps/keyguard/CMakeLists.txt | 5 +- tools/apps/keyguard/include/keyguard.h | 12 +- tools/apps/keyguard/include/widget.h | 2 +- tools/apps/keyguard/res/edje/keyguard.edc | 2 +- tools/apps/keyguard/src/main.c | 49 +- tools/apps/keyguard/src/ui.c | 2 +- tools/apps/keyguard/src/widget.c | 2 +- tools/apps/setup-wizard/CMakeLists.txt | 5 +- tools/apps/setup-wizard/include/krate-setup.h | 26 +- tools/apps/setup-wizard/include/setup-text.h | 14 +- tools/apps/setup-wizard/include/widget.h | 2 +- tools/apps/setup-wizard/res/edje/layout.edc | 2 +- tools/apps/setup-wizard/res/edje/setup.edc | 2 +- tools/apps/setup-wizard/res/edje/welcome.edc | 4 +- tools/apps/setup-wizard/src/main.c | 44 +- tools/apps/setup-wizard/src/security.c | 6 +- tools/apps/setup-wizard/src/ui.c | 12 +- tools/apps/setup-wizard/src/util.c | 28 +- tools/apps/setup-wizard/src/widget.c | 2 +- tools/cli/CMakeLists.txt | 7 +- tools/cli/krate-admin-cli.cpp | 62 +-- tools/gumd-scripts/20_krate-add.post | 2 +- tools/gumd-scripts/20_krate-remove.post | 2 +- 66 files changed, 4819 insertions(+), 216 deletions(-) create mode 100755 lib/CMakeLists.txt create mode 100644 lib/app-proxy.cpp create mode 100644 lib/client.cpp create mode 100644 lib/client.h create mode 100644 lib/context.h create mode 100644 lib/krate.pc.in create mode 100644 lib/krate/app-info-internal.h create mode 100644 lib/krate/app-proxy.cpp create mode 100644 lib/krate/app-proxy.h create mode 100644 lib/krate/debug.h create mode 100644 lib/krate/krate.cpp create mode 100644 lib/krate/krate.h create mode 100644 lib/krate/package-info-internal.h create mode 100644 lib/krate/package-proxy.cpp create mode 100644 lib/krate/package-proxy.h create mode 100644 lib/manager.cpp create mode 100644 lib/package-proxy.cpp create mode 100644 rmi/app-proxy.h create mode 100644 rmi/manager.h create mode 100644 rmi/package-proxy.h create mode 100644 server/app-bundle.cpp create mode 100644 server/app-bundle.h create mode 100644 server/app-proxy.cpp create mode 100644 server/context.h create mode 100644 server/launchpad.cpp create mode 100644 server/launchpad.h create mode 100644 server/main.cpp create mode 100644 server/manager.cpp create mode 100644 server/package-proxy.cpp create mode 100644 server/packman.cpp create mode 100644 server/packman.h create mode 100644 server/server.cpp create mode 100644 server/server.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f3f02d5..5fb2706 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,7 @@ ENDIF(NOT DEFINED CONF_DIR) ADD_DEFINITIONS(-DUG_WAYLAND) -#ADD_SUBDIRECTORY(${KRATE_LIB}) +ADD_SUBDIRECTORY(${KRATE_LIB}) ADD_SUBDIRECTORY(${KRATE_SERVER}) ADD_SUBDIRECTORY(${KRATE_MODULE}) ADD_SUBDIRECTORY(${KRATE_VOLUME}) diff --git a/krate.manifest b/krate.manifest index a76fdba..1badf9e 100644 --- a/krate.manifest +++ b/krate.manifest @@ -2,4 +2,7 @@ + + + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100755 index 0000000..f205925 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,59 @@ +# +# Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved +# +# 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. +# +SET(LIB_VERSION "${VERSION}") +SET(LIB_SOVERSION "0") + +SET(PC_FILE "${PROJECT_NAME}.pc") + +SET(SOURCES client.cpp + manager.cpp + app-proxy.cpp + package-proxy.cpp + krate/krate.cpp + krate/app-proxy.cpp + krate/package-proxy.cpp +) + +SET(CAPI_INCLUDE_FILES krate/krate.h + krate/app-proxy.h + krate/package-proxy.h +) + + +SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack") + +PKG_CHECK_MODULES(LIBS_DEPS REQUIRED + klay + glib-2.0 + capi-appfw-package-manager + capi-appfw-app-manager + capi-appfw-app-control + libtzplatform-config +) + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SOURCES}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${LIB_SOVERSION}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${LIB_VERSION}) + +INCLUDE_DIRECTORIES(SYSTEM ${LIBS_DEPS_INCLUDE_DIRS} ${DPM_POLICY} ${KRATE_LIB} ${PROJECT_SOURCE_DIR}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIBS_DEPS_LIBRARIES} pthread) + +CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY) + +INSTALL(FILES ${CMAKE_BINARY_DIR}/${PC_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) +INSTALL(FILES ${CAPI_INCLUDE_FILES} DESTINATION ${INCLUDE_INSTALL_DIR}/krate) diff --git a/lib/app-proxy.cpp b/lib/app-proxy.cpp new file mode 100644 index 0000000..112e673 --- /dev/null +++ b/lib/app-proxy.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "rmi/app-proxy.h" + +namespace Krate { + +AppProxy::AppProxy(KrateControlContext& ctx) + : context(ctx) +{ +} + +AppProxy::~AppProxy() +{ +} + +AppProxy::AppInfo AppProxy::getAppInfo(const std::string& name, const std::string& appid) +{ + try { + return context->methodCall("AppProxy::getAppInfo", name, appid); + } catch (runtime::Exception& e) {} + return AppProxy::AppInfo(); +} + +int AppProxy::createIterator(const std::string& krate) +{ + try { + return context->methodCall("AppProxy::createIterator", krate); + } catch (runtime::Exception& e) {} + return -1; +} + +AppProxy::AppInfo AppProxy::getIteratorValue(int iterator) +{ + try { + return context->methodCall("AppProxy::getIteratorValue", iterator); + } catch (runtime::Exception& e) {} + return AppProxy::AppInfo(); +} + +bool AppProxy::nextIterator(int iterator) +{ + try { + return context->methodCall("AppProxy::nextIterator", iterator); + } catch (runtime::Exception& e) {} + return false; +} + +int AppProxy::destroyIterator(int iterator) +{ + try { + return context->methodCall("AppProxy::destroyIterator", iterator); + } catch (runtime::Exception& e) {} + return -1; +} + +int AppProxy::launch(const std::string& name, const AppProxy::Bundle& bundle) +{ + try { + return context->methodCall("AppProxy::launch", name, bundle); + } catch (runtime::Exception& e) { + return -1; + } +} + +int AppProxy::resume(const std::string& name, const std::string& appid) +{ + try { + return context->methodCall("AppProxy::resume", name, appid); + } catch (runtime::Exception& e) { + return -1; + } +} + +int AppProxy::terminate(const std::string& name, const std::string& appid) +{ + try { + return context->methodCall("AppProxy::terminate", name, appid); + } catch (runtime::Exception& e) { + return -1; + } +} + +bool AppProxy::isRunning(const std::string& name, const std::string& appid) +{ + try { + return context->methodCall("AppProxy::isRunning", name, appid); + } catch (runtime::Exception& e) { + return -1; + } +} + +} // namespace Krate diff --git a/lib/client.cpp b/lib/client.cpp new file mode 100644 index 0000000..3e3bc58 --- /dev/null +++ b/lib/client.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "client.h" + +namespace { + +const std::string SUBSCRIBER_REGISTER = "Server::registerNotificationSubscriber"; +const std::string SUBSCRIBER_UNREGISTER = "Server::unregisterNotificationSubscriber"; + +const std::string KRATE_MANAGER_ADDRESS = "/tmp/.krate.sock"; + +} // namespace + + +KrateContext::KrateContext() noexcept +{ +} + +KrateContext::~KrateContext() noexcept +{ + disconnect(); +} + +int KrateContext::connect(const std::string& address) noexcept +{ + try { + client.reset(new rmi::Client(address)); + client->connect(); + } catch (runtime::Exception& e) { + return -1; + } + + return 0; +} + +int KrateContext::connect() noexcept +{ + return connect(KRATE_MANAGER_ADDRESS); +} + +void KrateContext::disconnect() noexcept +{ + client.reset(); +} + +int KrateContext::subscribeSignal(const std::string& name, + const SignalListener& listener, + void* data) +{ + auto listenerDispatcher = [listener, data](std::string &name, std::string &from, std::string &object) { + listener(from.c_str(), object.c_str(), data); + }; + + try { + return client->subscribe(SUBSCRIBER_REGISTER, + name, listenerDispatcher); + } catch (runtime::Exception& e) { + std::cout << e.what() << std::endl; + return -1; + } +} + +int KrateContext::unsubscribeSignal(int subscriberId) +{ + return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId); +} diff --git a/lib/client.h b/lib/client.h new file mode 100644 index 0000000..f8d1678 --- /dev/null +++ b/lib/client.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __POLICY_CLIENT_H__ +#define __POLICY_CLIENT_H__ + +#include +#include +#include + +#include + +typedef std::function KrateChangeListener; +typedef std::function SignalListener; + +class KrateContext { +public: + typedef std::unique_ptr KrateControlContext; + + KrateContext() noexcept; + ~KrateContext() noexcept; + + int connect() noexcept; + int connect(const std::string& address) noexcept; + void disconnect() noexcept; + + int subscribeSignal(const std::string& name, const SignalListener& listener, void* data); + int unsubscribeSignal(int subscriberId); + + template + Krate createKrateInterface(Args&&... args) noexcept + { + return Krate(getKrateControlContext(), std::forward(args)...); + } + +private: + KrateControlContext& getKrateControlContext() + { + return client; + } + + KrateControlContext client; +}; + +KrateContext& GetKrateContext(void* handle); +#endif //__POLICY_CLIENT_H__ diff --git a/lib/context.h b/lib/context.h new file mode 100644 index 0000000..f1908d1 --- /dev/null +++ b/lib/context.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __KRATE_CONTEXT__ +#define __KRATE_CONTEXT__ + +#include "client.h" + +using KrateControlContext = ::KrateContext::KrateControlContext; + +#endif //!__KRATE_CONTEXT__ diff --git a/lib/krate.pc.in b/lib/krate.pc.in new file mode 100644 index 0000000..175f23b --- /dev/null +++ b/lib/krate.pc.in @@ -0,0 +1,12 @@ +# Package Information for pkg-config + +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@LIB_INSTALL_DIR@ +includedir=@INCLUDE_INSTALL_DIR@ + +Name: @PROJECT_NAME@ +Description: Tizen @PROJECT_NAME@ Client library +Version: @VERSION@ +Libs: -L${libdir} -l@PROJECT_NAME@ +Cflags: -I${includedir}/@PROJECT_NAME@ diff --git a/lib/krate/app-info-internal.h b/lib/krate/app-info-internal.h new file mode 100644 index 0000000..96f1a7a --- /dev/null +++ b/lib/krate/app-info-internal.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __DPM_APP_INFO_INTERNAL_H__ +#define __DPM_APP_INFO_INTERNAL_H__ + +#include + +// pkgmgr-info : include/pkgmgrinfo_basic.h +typedef struct icon_x { + char *text; + char *lang; + char *section; + char *size; + char *resolution; + char *dpi; +} icon_x; + +// pkgmgr-info : include/pkgmgrinfo_basic.h +typedef struct label_x { + char *name; + char *text; + char *lang; +} label_x; + +// pkgmgr-info : include/pkgmgrinfo_basic.h +typedef struct application_x { + char *appid; /*attr*/ + char *exec; /*attr*/ + char *nodisplay; /*attr, default: "false"*/ + char *multiple; /*attr, default: "false"*/ + char *taskmanage; /*attr, default: "true"*/ + char *enabled; /*attr, default: "true"*/ + char *type; /*attr*/ + char *categories; /*attr*/ + char *extraid; /*attr*/ + char *hwacceleration; /*attr, default: "default"*/ + char *screenreader; /*attr, default: "use-system-setting"*/ + char *mainapp; /*attr, default: "false"*/ + char *package; /*set from package_x*/ + char *recentimage; /*attr, default: "false"*/ + char *launchcondition; /*attr, default: "false"*/ + char *indicatordisplay; /*attr, default: "true"*/ + char *portraitimg; /*attr*/ + char *landscapeimg; /*attr*/ + char *effectimage_type; /*attr, default: "image"*/ + char *guestmode_visibility; /*attr, default: "true"*/ + char *component; /*no xml part*/ + char *permission_type; /*attr, default: "normal"*/ + char *component_type; /*attr, default: "uiapp"*/ + char *preload; /*no xml part*/ + char *submode; /*attr, default: "false"*/ + char *submode_mainid; /*attr, default: "false"*/ + char *process_pool; /*attr, default: "false"*/ + char *installed_storage; + char *autorestart; /*attr, default: "false"*/ + char *onboot; /*attr, default: "false"*/ + char *support_disable; /*set from package_x*/ + char *ui_gadget; /*attr, default: "false"*/ + char *launch_mode; /*attr, default: "single"*/ + char *ambient_support; /*attr, default: "false"*/ + char *alias_appid; /*attr*/ + char *effective_appid; /*attr*/ + char *package_type; /*set from package_x*/ + char *tep_name; /*set from package_x*/ + char *zip_mount_file; /*set from package_x*/ + char *root_path; /*set from package_x*/ + char *api_version; /*set from package_x*/ + char *for_all_users; /**< Flag that indicates if the package is available for everyone or for current user only, no xml part*/ + char *is_disabled; /**< Flag that indicates if the application is disabled or not, no xml part*/ + char *splash_screen_display; /*attr, default: "true"*/ + GList *label; /*element*/ + GList *icon; /*element*/ + GList *image; /*element*/ + GList *category; /*element*/ + GList *metadata; /*element*/ + GList *permission; /*element*/ + GList *launchconditions; /*element*/ + GList *notification; /*element*/ + GList *datashare; /*element*/ + GList *datacontrol; /*element*/ + GList *background_category; /*element*/ + GList *appcontrol; /*element*/ + GList *splashscreens; /*element*/ +} application_x; + +// pkgmgr-info : include/pkgmgrinfo_private.h +typedef struct _pkgmgr_appinfo_x { + const char *package; + char *locale; + int app_component; + application_x *app_info; +} pkgmgr_appinfo_x; + +// app-manager : src/app_info.c +typedef struct app_info_s { + char *app_id; + pkgmgr_appinfo_x *pkg_app_info; +} app_info_s; + + +#endif //__DPM_APP_INFO_INTERNAL_H__ diff --git a/lib/krate/app-proxy.cpp b/lib/krate/app-proxy.cpp new file mode 100644 index 0000000..449520d --- /dev/null +++ b/lib/krate/app-proxy.cpp @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "debug.h" +#include "krate.h" +#include "app-proxy.h" +#include "app-info-internal.h" + +#include "client.h" +#include "rmi/app-proxy.h" + +using namespace Krate; + +struct krate_app_proxy_s { + Krate::AppProxy proxy; + std::string krateName; +}; + +static inline krate_app_proxy_s* getInstance(krate_app_proxy_h handle) +{ + return reinterpret_cast(handle); +} + +static app_info_h make_app_info_handle(const Krate::AppProxy::AppInfo& info) +{ + if (info.id.empty()) { + return NULL; + } + + application_x* app = (application_x*)::malloc(sizeof(application_x)); + pkgmgr_appinfo_x* pkgappinfo = (pkgmgr_appinfo_x*)::malloc(sizeof(pkgmgr_appinfo_x)); + app_info_s* appinfo = (app_info_s*)::malloc(sizeof(struct app_info_s)); + + ::memset(appinfo, 0, sizeof(app_info_s)); + appinfo->app_id = ::strdup(info.id.c_str()); + appinfo->pkg_app_info = pkgappinfo; + + ::memset(pkgappinfo, 0, sizeof(pkgmgr_appinfo_x)); + pkgappinfo->package = ::strdup(info.package.c_str()); + pkgappinfo->locale = ::strdup(info.locale.c_str()); + pkgappinfo->app_component = info.componentType; + pkgappinfo->app_info = app; + + ::memset(app, 0, sizeof(application_x)); + app->appid = ::strdup(info.id.c_str()); + app->nodisplay = ::strdup(info.isNoDisplayed? "true":"false"); + app->taskmanage = ::strdup(info.isTaskManaged? "true":"false"); + app->type = ::strdup(info.type.c_str()); + + icon_x* icon = (icon_x*)::calloc(1, sizeof(icon_x)); + icon->text = ::strdup(info.icon.c_str()); + icon->lang = ::strdup(info.locale.c_str()); + app->icon = ::g_list_append(NULL, icon); + + label_x* label = (label_x*)::calloc(1, sizeof(label_x)); + label->text = ::strdup(info.label.c_str()); + label->lang = ::strdup(info.locale.c_str()); + app->label = ::g_list_append(NULL, label); + + return reinterpret_cast(appinfo); +} + +int krate_app_proxy_create(krate_manager_h manager, const char* name, krate_app_proxy_h *handle) +{ + RET_ON_FAILURE(manager, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(name, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + + krate_app_proxy_s* instance = new krate_app_proxy_s { + GetKrateContext(manager).createKrateInterface(), + name + }; + + *handle = reinterpret_cast(instance); + return KRATE_ERROR_NONE; +} + +int krate_app_proxy_destroy(krate_app_proxy_h handle) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + + delete reinterpret_cast(handle); + + return KRATE_ERROR_NONE; +} + +int krate_app_proxy_get_app_info(krate_app_proxy_h handle, const char* app_id, app_info_h* app_info) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(app_id, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(app_info, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + auto& proxy = instance->proxy; + const std::string& name = instance->krateName; + + const auto info = proxy.getAppInfo(name, app_id); + app_info_h ret = make_app_info_handle(info); + if (ret == NULL) { + return KRATE_ERROR_INVALID_PARAMETER; + } + + *app_info = ret; + + return KRATE_ERROR_NONE; +} + +int krate_app_proxy_foreach_app_info(krate_app_proxy_h handle, app_manager_app_info_cb callback, void *user_data) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(callback, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + auto& proxy = instance->proxy; + const std::string& name = instance->krateName; + + int iter = proxy.createIterator(name); + do { + app_info_h info = make_app_info_handle(proxy.getIteratorValue(iter)); + int ret = callback(info, user_data); + app_info_destroy(info); + if (!ret) { + break; + } + } while (proxy.nextIterator(iter)); + proxy.destroyIterator(iter); + + return KRATE_ERROR_NONE; +} + +static bool appExtraCallback(app_control_h app_control, const char *key, void *user_data) +{ + Krate::AppProxy::Bundle *bundle = reinterpret_cast(user_data); + Krate::AppProxy::Bundle::Extra extra; + bool isArray; + + extra.key = key; + + app_control_is_extra_data_array(app_control, key, &isArray); + if (isArray) { + char **values; + int length = 0; + app_control_get_extra_data_array(app_control, key, &values, &length); + for (int i = 0; i < length; i++) { + extra.value.push_back(values[i]); + free(values[i]); + } + free(values); + } else { + char *value; + app_control_get_extra_data(app_control, key, &value); + extra.value.push_back(value); + free(value); + } + bundle->extraData.push_back(extra); + + return true; +} + +int krate_app_proxy_send_launch_request(krate_app_proxy_h handle, app_control_h app_control) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(app_control, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + auto& proxy = instance->proxy; + const std::string& name = instance->krateName; + char *str; + + Krate::AppProxy::Bundle bundle; + app_control_get_operation(app_control, &str); + if (str != NULL) { + bundle.operation = str; + free(str); + str = NULL; + } + app_control_get_uri(app_control, &str); + if (str != NULL) { + bundle.uri = str; + free(str); + str = NULL; + } + app_control_get_mime(app_control, &str); + if (str != NULL) { + bundle.mime = str; + free(str); + str = NULL; + } + app_control_get_category(app_control, &str); + if (str != NULL) { + bundle.category = str; + free(str); + str = NULL; + } + app_control_get_app_id(app_control, &str); + if (str != NULL) { + bundle.appId = str; + free(str); + str = NULL; + } + app_control_foreach_extra_data(app_control, appExtraCallback, &bundle); + + return proxy.launch(name, bundle); +} + +int krate_app_proxy_terminate(krate_app_proxy_h handle, const char* app_id) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(app_id, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + auto& proxy = instance->proxy; + const std::string& name = instance->krateName; + + return proxy.terminate(name, app_id); +} + +int krate_app_proxy_resume(krate_app_proxy_h handle, const char* app_id) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(app_id, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + auto& proxy = instance->proxy; + const std::string& name = instance->krateName; + + return proxy.resume(name, app_id); +} + +int krate_app_proxy_is_running(krate_app_proxy_h handle, const char* app_id, int *result) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(app_id, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(result, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + auto& proxy = instance->proxy; + const std::string& name = instance->krateName; + + *result = proxy.isRunning(name, app_id); + return KRATE_ERROR_NONE; +} diff --git a/lib/krate/app-proxy.h b/lib/krate/app-proxy.h new file mode 100644 index 0000000..02ec714 --- /dev/null +++ b/lib/krate/app-proxy.h @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __CAPI_KRATE_APP_PROXY_H__ +#define __CAPI_KRATE_APP_PROXY_H__ + +#include +#include +#include + +#include + +/** + * @file app-info.h + * @brief This file provides APIs to get the information of applications in the krate + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_KRATE_APPLICATION_INFO_MODULE + * @{ + */ + +/** + * @brief The krate application manager handle + * @since_tizen 3.0 + * @see krate_app_proxy_create() + * @see krate_app_proxy_destroy() + */ +typedef void* krate_app_proxy_h; + +/** + * @brief Acquires the krate application manager handle + * @details This API acquires krate application manager handle required to call + * the krate application manager APIs. + * @since_tizen 3.0 + * @param[in] manager The krate manager handle + * @param[in] name The krate name + * @param[out] handle The krate app proxy handle + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_CONNECTION_REFUSED Connection refused + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @see krate_manager_create() + * @see krate_app_proxy_create() + * @see get_last_result() + */ +KRATE_API int krate_app_proxy_create(krate_manager_h manager, const char* name, krate_app_proxy_h* handle); + +/** + * @brief Releases the krate application manager handle + * @details This API must be called if interaction with the krate application + * manager handle is no longer required. + * @since_tizen 3.0 + * @param[in] context The device policy manager context + * @param[in] handle The krate application manager handle + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @pre The handle must be created by krate_app_proxy_create() + * @see krate_app_proxy_create() + */ +KRATE_API int krate_app_proxy_destroy(krate_app_proxy_h handle); + +/** + * @brief Gets the application information for the given application in the krate. + * @details This API gets application information handle required to get + * information of the application in the krate + * @since_tizen 3.0 + * @param[in] handle The krate application manager handle + * @param[in] appid The application ID + * @return Krate application handle on success, otherwise NULL + * @remark The specific error code can be obtained by using the + * get_last_result() method. Error codes are described in + * exception section. + * @exception #KRATE_ERROR_NONE No error + * @exception #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #KRATE_ERROR_TIMED_OUT Time out + * @see krate_app_proxy_create() + * @see krate_app_proxy_create() + * @see krate_application_release() + * @see application_manager_get_application_info() + * @see get_last_result() + */ +KRATE_API int krate_app_proxy_get_app_info(krate_app_proxy_h handle, const char* appid, app_info_h* app_info); + +/** + * @brief Retrieves all the handles of the application in the krate. + * @details This API calls app_manager_app_info_cb() once for each application + * ID with traversing the installed application list in the krate. + * @since_tizen 3.0 + * @param[in] handle The krate application manager handle + * @param[in] callback The iteration callback function + * @param[in] user_data The user data passed to the callback function + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The handle must be created by krate_app_proxy_create(). + * @see krate_app_proxy_create() + * @see krate_app_proxy_create() + * @see application_manager_foreach_app_info() + */ +KRATE_API int krate_app_proxy_foreach_app_info(krate_app_proxy_h handle, app_manager_app_info_cb callback, void *user_data); + +/** + * @brief Launch the application located at the given path into the krate. + * @details Administrator can use this API to launch the application in the + * krate. + * @since_tizen 3.0 + * @param[in] handle The krate application manager handle + * @param[in] app_control The app_control handle + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @retval #KRATE_ERROR_NO_SUCH_FILE No such application file + * @retval #KRATE_ERROR_PERMISSION_DENIED The application does not have + * the privilege to call this API or the caller is not the owner + * of the krate + * @pre The handle must be created by krate_app_proxy_create(). + * @pre The krate corresponding to the given name must be + * created before use of this API. + * @see krate_app_proxy_create() + * @see krate_app_proxy_destroy() + * @see krate_app_proxy_resume() + * @see krate_app_proxy_terminate() + * @see krate_is_running_app() + * @see app_control_send_launch_request() + */ +KRATE_API int krate_app_proxy_send_launch_request(krate_app_proxy_h handle, app_control_h app_control); + +/** + * @brief Terminate the application located at the given path into the krate. + * @details Administrator can use this API to terminate the application in + * the krate. + * @since_tizen 3.0 + * @param[in] handle The krate application manager handle + * @param[in] appid The application ID to be terminated + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @retval #KRATE_ERROR_NO_SUCH_FILE No such application file + * @retval #KRATE_ERROR_PERMISSION_DENIED The application does not have + * the privilege to call this API or the caller is not the owner + * of the krate + * @pre The handle must be created by krate_app_proxy_create(). + * @pre The krate corresponding to the given name must be + * created before use of this API. + * @see krate_app_proxy_create() + * @see krate_app_proxy_destroy() + * @see krate_app_proxy_resume() + * @see krate_app_proxy_send_launch_request() + * @see krate_is_running_app() + * @see app_control_send_terminate_request() + * @see app_manager_send_terminate_bt_app() + */ +KRATE_API int krate_app_proxy_terminate(krate_app_proxy_h handle, const char* appid); + +/** + * @brief Resume the application located at the given path into the krate. + * @details Administrator can use this API to resume the application in the + * krate. + * @since_tizen 3.0 + * @param[in] handle The krate application manager handle + * @param[in] appid The application ID to be resumed + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @retval #KRATE_ERROR_NO_SUCH_FILE No such application file + * @retval #KRATE_ERROR_PERMISSION_DENIED The application does not have + * the privilege to call this API or the caller is not the owner + * of the krate + * @pre The handle must be created by krate_app_proxy_create(). + * @pre The krate corresponding to the given name must be + * created before use of this API. + * @see krate_app_proxy_create() + * @see krate_app_proxy_destroy() + * @see krate_app_proxy_send_launch_request() + * @see krate_app_proxy_terminate() + * @see app_manager_resume_app() + */ +KRATE_API int krate_app_proxy_resume(krate_app_proxy_h handle, const char* appid); + +/** + * @brief Checks whether the application in the krate is running. + * @details This API can be used to check whether the application in the krate + * is running. + * @since_tizen 3.0 + * @param[in] handle The krate application manager handle + * @param[in] appid The application ID + * @param[out] result true if the application is running, + * otherwise false if the application is not running + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_NO_DATA No such pacakge to check + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @pre The handle must be created by krate_app_proxy_create(). + * @see krate_app_proxy_create() + * @see krate_app_proxy_destroy() + * @see krate_app_proxy_send_launch_request() + * @see krate_app_proxy_terminate() + * @see app_manager_is_running_app() + */ +KRATE_API int krate_app_proxy_is_running(krate_app_proxy_h handle, const char* appid, int* result); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CAPI_KRATE_APP_PROXY_H__ */ diff --git a/lib/krate/debug.h b/lib/krate/debug.h new file mode 100644 index 0000000..719e478 --- /dev/null +++ b/lib/krate/debug.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __CAPI_KRATE_ASSERT_H__ +#define __CAPI_KRATE_ASSERT_H__ + +#define RET_ON_FAILURE(cond, ret) \ +{ \ + if (!(cond)) \ + return (ret); \ +} + +#endif //! __CAPI_KRATE_ASSERT_H__ diff --git a/lib/krate/krate.cpp b/lib/krate/krate.cpp new file mode 100644 index 0000000..6f428f3 --- /dev/null +++ b/lib/krate/krate.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "debug.h" +#include "krate.h" + +#include "client.h" +#include "rmi/manager.h" + + +using namespace Krate; + +KrateContext& GetKrateContext(void* handle) +{ + return *reinterpret_cast(handle); +} + +int krate_manager_create(krate_manager_h* handle) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + + KrateContext* client = new(std::nothrow) KrateContext(); + + RET_ON_FAILURE(handle, KRATE_ERROR_CONNECTION_REFUSED); + + if (client->connect() < 0) { + delete client; + RET_ON_FAILURE(handle, KRATE_ERROR_CONNECTION_REFUSED); + } + + *handle = reinterpret_cast(client); + + return KRATE_ERROR_NONE; +} + +int krate_manager_destroy(krate_manager_h handle) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + + delete &GetKrateContext(handle); + + return KRATE_ERROR_NONE; +} + +int krate_manager_add_event_cb(krate_manager_h handle, const char* event, krate_event_cb callback, void* user_data, int *id) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(event, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(callback, KRATE_ERROR_INVALID_PARAMETER); + + KrateContext &context = GetKrateContext(handle); + int ret = context.subscribeSignal(std::string("Manager::") + event, + callback, user_data); + if (ret < 0) + return KRATE_ERROR_INVALID_PARAMETER; + + *id = ret; + return KRATE_ERROR_NONE; +} + +int krate_manager_remove_event_cb(krate_manager_h handle, int callback_id) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(callback_id >= 0, KRATE_ERROR_INVALID_PARAMETER); + + KrateContext &context = GetKrateContext(handle); + int ret = context.unsubscribeSignal(callback_id); + if (ret) + return KRATE_ERROR_INVALID_PARAMETER; + + return KRATE_ERROR_NONE; +} + +int krate_manager_create_krate(krate_manager_h handle, const char* name, const char* manifest) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(name, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(manifest, KRATE_ERROR_INVALID_PARAMETER); + + KrateContext &client = GetKrateContext(handle); + Krate::Manager krate = client.createKrateInterface(); + return krate.createKrate(name, manifest); +} + +int krate_manager_destroy_krate(krate_manager_h handle, const char* name) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(name, KRATE_ERROR_INVALID_PARAMETER); + + KrateContext &client = GetKrateContext(handle); + Krate::Manager krate = client.createKrateInterface(); + return krate.removeKrate(name); +} + +int krate_manager_get_krate_state(krate_manager_h handle, const char* name, krate_state_e *state) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(name, KRATE_ERROR_INVALID_PARAMETER); + + KrateContext &client = GetKrateContext(handle); + Krate::Manager krate = client.createKrateInterface(); + + int result = krate.getKrateState(name); + if (result == 0) { + return KRATE_ERROR_NO_DATA; + } + + *state = (krate_state_e)result; + return KRATE_ERROR_NONE; +} + +int krate_manager_foreach_name(krate_manager_h handle, krate_state_e state, + krate_manager_foreach_cb callback, void* user_data) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(callback, KRATE_ERROR_INVALID_PARAMETER); + + KrateContext &client = GetKrateContext(handle); + Krate::Manager krate = client.createKrateInterface(); + std::vector list = krate.getKrateList(state); + for (std::vector::iterator it = list.begin(); + it != list.end(); it++) { + if (!callback((*it).c_str(), user_data)) + break; + } + + return KRATE_ERROR_NONE; +} + +int krate_manager_reset_krate_password(krate_manager_h handle, const char* name, const char* new_password) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(name, KRATE_ERROR_INVALID_PARAMETER); + + if (new_password == NULL) { + new_password = ""; + } + + KrateContext &client = GetKrateContext(handle); + Krate::Manager krate = client.createKrateInterface(); + + return krate.resetKratePassword(name, new_password); +} diff --git a/lib/krate/krate.h b/lib/krate/krate.h new file mode 100644 index 0000000..15aa135 --- /dev/null +++ b/lib/krate/krate.h @@ -0,0 +1,309 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __KRATE_KRATE_MANAGER_H__ +#define __KRATE_KRATE_MANAGER_H__ + +#include + +/** + * @file krate.h + * @brief This file defines common data types required to krate APIs. + */ + +#ifndef KRATE_API +#define KRATE_API __attribute__((visibility("default"))) +#endif // API + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_KRATE_KRATE_MANAGER_MODULE + * @{ + */ + +/** + * @brief Enumeration of device policy API errors + * @since_tizen 3.0 + */ +typedef enum { + KRATE_ERROR_NONE = TIZEN_ERROR_NONE, /**< The operation was successful */ + KRATE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + KRATE_ERROR_CONNECTION_REFUSED = TIZEN_ERROR_CONNECTION_REFUSED, /**< Connection refused */ + KRATE_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< Time out */ + KRATE_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Access privilege is not sufficient */ + KRATE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Operation is not supported */ + KRATE_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< No such file or directory */ + KRATE_ERROR_FILE_EXISTS = TIZEN_ERROR_FILE_EXISTS, /**< File exists */ + KRATE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + KRATE_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA /**< No Data */ +} krate_error_type_e; + +/** + * @brief The krate manager handle + * @details The krate manager handle is an abstraction of the + * logical connection between the krate manager and it's client. + * The krate manager handle must be created by using + * krate_manager_create() before attempting to use almost any of + * the krate related APIs, and it should be freed when interaction + * with the krate manager is no longer required. + * To release the handle, use krate_manager_destroy(). + * @since_tizen 3.0 + * @see krate_manager_create() + * @see krate_manager_destroy() + */ +typedef void* krate_manager_h; + +/** + * @brief Creates the krate manager handle. + * @details This API creates krate manager handle required to + * the krate related APIs. + * This API is also used to verify whether caller is authorized + * or not. + * @since_tizen 3.0 + * @param[out] handle The krate manager handle + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_CONNECTION_REFUSED Connection refused + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @see krate_manager_destroy() + * @see get_last_result() + */ +KRATE_API int krate_manager_create(krate_manager_h *handle); + +/** + * @brief Releases the krate manager handle. + * @details This API must be called if interaction with the krate manager is + * no longer required. + * @since_tizen 3.0 + * @param[in] handle The krate manager handle + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The handle must be created by krate_manager_create() + * @see krate_manager_create() + */ +KRATE_API int krate_manager_destroy(krate_manager_h handle); + +/** + * @brief Called when a krate raises a event. + * @since_tizen 3.0 + * @param[in] name The krate name + * @param[in] object The object name triggered the event + * @param[in] user_data The user data passed from krate_manager_add_event_cb + * @see krate_manager_add_event_cb() + * @see krate_manager_remove_event_cb() + */ +typedef void(*krate_event_cb)(const char* name, const char* object, void* user_data); + +/** + * @brief Adds krate event callback. + * @details This API can be used to receive events sent by krate + * The callback specified to this function is automatically called when + * the krate is created or removed. + * @since_tizen 3.0 + * @param[in] context The krate_manager handle + * @param[in] event The event name to receive + * @param[in] callback The event callback + * @param[in] user_data The user data passed to the callback function + * @param[out] id Signal identifier + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @pre The handle must be created by krate_manager_create(). + * @see krate_manager_create() + * @see krate_manager_destroy() + * @see krate_manager_remove_event_cb() + */ +KRATE_API int krate_manager_add_event_cb(krate_manager_h handle, + const char* event, + krate_event_cb callback, void* user_data, + int* id); + +/** + * @brief Removes krate event callback. + * @details This API removes krate event callback + * @since_tizen 3.0 + * @param[in] context The krate manager handle + * @param[in] id Signal identifier + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @pre The context must be created by krate_manager_create(). + * @see krate_manager_create() + * @see krate_manager_destroy() + * @see krate_manager_add_event_cb() + */ +KRATE_API int krate_manager_remove_event_cb(krate_manager_h handle, int id); + +/** + * @brief Creates a new krate. + * @details This API creates a container. All file system objects neeeded + * will be also created. manifest XML passed by parameter will be + * used when the krate is running. + * @since_tizen 3.0 + * @param[in] handle The krate manager handle + * @param[in] name The krate name to be created + * @param[in] manifest The manifest XML to be used when the krate is runned. + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @retval #KRATE_ERROR_PERMISSION_DENIED The application does not have + * the privilege to call this API + * @pre The handle must be created by krate_manager_create(). + * @see krate_manager_create() + * @see krate_manager_destroy() + * @see krate_manager_destroy_krate() + * @see krate_manager_create_krate_iterator() + */ +KRATE_API int krate_manager_create_krate(krate_manager_h handle, + const char* name, + const char* manifest); + +/** + * @brief Removes existing krate. + * @details This removes krate. All file system objects created for the krate + * will be also erased. + * @since_tizen 3.0 + * @param[in] handle The krate manager handle + * @param[in] name The krate name to be removed + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @retval #KRATE_ERROR_PERMISSION_DENIED The application does not have + * the privilege to call this API or the caller is not the owner + * of the krate + * @pre The handle must be created by krate_manager_create(). + * @pre The krate corresponding to the given name must be + * created before use of this API. + * @see krate_manager_create() + * @see krate_manager_destroy() + * @see krate_manager_create_krate() + * @see krate_manager_create_krate_iterator() + */ +KRATE_API int krate_manager_destroy_krate(krate_manager_h handle, + const char* name); + +/* + * @brief Enumeration for krate state + * @since_tizen 3.0 + */ +typedef enum { + KRATE_STATE_LOCKED = 0x01, /**< Krate has been defined, but it can not start. */ + KRATE_STATE_RUNNING = 0x02, /**< Krate has been started. */ + KRATE_STATE_ALL = 0xff /**< This presents all of the state */ +} krate_state_e; + +/** + * @brief Gets the krate state. + * @details This API can be used to get the state of the krate. The krate can + * have one of the three states(running, locked). + * @since_tizen 3.0 + * @param[in] handle The krate policy handle + * @param[in] name The krate name + * @param[out] state The krate state + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_NO_DATA No such krate to get state + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @pre The handle must be created by krate_manager_create(). + * @see krate_manager_create() + * @see krate_manager_destroy() + * @see krate_manager_create_krate() + * @see krate_manager_destroy_krate() + */ +KRATE_API int krate_manager_get_krate_state(krate_manager_h handle, + const char* name, + krate_state_e* state); + +/** + * @brief Called to get all the name of created krates. + * @since_tizen 3.0 + * @param[in] name The krate name + * @param[in] user_data The user data passed from krate_manager_foreach_name + * @return true to continue with the next iteration of the loop, otherwise false to break out out the loop + * @see krate_manager_foreach_name() + */ +typedef bool(*krate_manager_foreach_cb)(const char* name, void* user_data); + +/** + * @brief Retrieves all the name of created krates + * @details This API calls krate_manager_foreach_cb() once for each krate name + * with traversing the created krates list. + * @since_tizen 3.0 + * @param[in] handle The krate policy handle + * @param[in] state a combination of the krate state to look + * @param[in] callback The iteration callback function + * @param[in] user_data The user data passed to the callback function + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The handle must be created by krate_manager_create(). + * @see krate_manager_create() + * @see krate_manager_destroy() + * @see krate_manager_create_krate() + * @see krate_manager_destroy_krate() + */ +KRATE_API int krate_manager_foreach_name(krate_manager_h handle, + krate_state_e state, + krate_manager_foreach_cb callback, + void* user_data); + +/** + * @brief Reset password for the krate. + * @details This API can be used to set password for the krate. The password + * of the krate can be used for authenticating user. + * @since_tizen 3.0 + * @param[in] handle The krate policy handle + * @param[in] name The krate name + * @param[out] new_password new password if NULL, existing password will be removed + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_NO_DATA No such krate to get state + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @pre The handle must be created by krate_manager_create(). + * @see krate_manager_create() + * @see krate_manager_destroy() + */ +KRATE_API int krate_manager_reset_krate_password(krate_manager_h handle, + const char* name, const char* new_password); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __KRATE_KRATE_MANAGER_H__ */ diff --git a/lib/krate/package-info-internal.h b/lib/krate/package-info-internal.h new file mode 100644 index 0000000..d84fa79 --- /dev/null +++ b/lib/krate/package-info-internal.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __KRATE_PACKAGE_INFO_INTERNAL_H__ +#define __KRATE_PACKAGE_INFO_INTERNAL_H__ + +#include + +// pkgmgr-info : include/pkgmgrinfo_basic.h +typedef struct icon_x { + char *text; + char *lang; + char *section; + char *size; + char *resolution; + char *dpi; +} icon_x; + +// pkgmgr-info : include/pkgmgrinfo_basic.h +typedef struct description_x { + char *name; + char *text; + char *lang; +} description_x; + +// pkgmgr-info : include/pkgmgrinfo_basic.h +typedef struct label_x { + char *name; + char *text; + char *lang; +} label_x; + +// pkgmgr-info : include/pkgmgrinfo_basic.h +typedef struct author_x { + char *email; + char *href; + char *text; + char *lang; +} author_x; + +// pkgmgr-info : include/pkgmgrinfo_basic.h +typedef struct package_x { + char *for_all_users; /**< Flag that indicates if the package is available for everyone or for current user only, no xml part*/ + char *package; /**< package name, attr*/ + char *version; /**< package version, attr*/ + char *installlocation; /**< package install location, attr, default: "internal-only"*/ + char *ns; /** +#include +#include + +#include +#include +#include +#include + +#include "debug.h" +#include "krate.h" +#include "package-proxy.h" +#include "package-info-internal.h" + +#include "client.h" +#include "rmi/package-proxy.h" + +using namespace Krate; + +struct krate_package_proxy_s { + PackageProxy proxy; + std::string krateName; + pkgmgr_client* pNativeHandle; + package_manager_event_cb pCallback; + void *pCallbackUserData; +}; + +static inline krate_package_proxy_s* getInstance(krate_package_proxy_h handle) +{ + return reinterpret_cast(handle); +} + +static int packageEventHandler(uid_t target_uid, int req_id, + const char *pkg_type, const char *pkg_name, + const char *key, const char *val, + const void *pmsg, void *data) +{ + static auto event_type = (package_manager_event_type_e)-1; + auto event_state = PACKAGE_MANAGER_EVENT_STATE_FAILED; + auto instance = getInstance(data); + std::string keystr = key; + int progress = 0; + + if (target_uid != tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) { + try { + runtime::User pkgOwner(target_uid); + if (pkgOwner.getName() != instance->krateName) { + return PACKAGE_MANAGER_ERROR_NONE; + } + } catch (runtime::Exception &e) { + return PACKAGE_MANAGER_ERROR_NONE; + } + } + + std::transform(keystr.begin(), keystr.end(), keystr.begin(), ::tolower); + + if (keystr == "start") { + if (val == NULL) { + return PACKAGE_MANAGER_ERROR_INVALID_PARAMETER; + } + + std::string valstr = val; + std::transform(valstr.begin(), valstr.end(), valstr.begin(), ::tolower); + if (valstr == "install") { + event_type = PACKAGE_MANAGER_EVENT_TYPE_INSTALL; + } else if (valstr == "uninstall") { + event_type = PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL; + } else if (valstr == "update") { + event_type = PACKAGE_MANAGER_EVENT_TYPE_UPDATE; + } else { + return PACKAGE_MANAGER_ERROR_INVALID_PARAMETER; + } + + event_state = PACKAGE_MANAGER_EVENT_STATE_STARTED; + } else if (keystr == "install_percent" || + keystr == "progress_percent") { + event_state = PACKAGE_MANAGER_EVENT_STATE_PROCESSING; + progress = std::stoi(val); + } else if (keystr == "error") { + event_state = PACKAGE_MANAGER_EVENT_STATE_FAILED; + } else if (keystr == "end" || + keystr == "ok") { + event_state = PACKAGE_MANAGER_EVENT_STATE_COMPLETED; + progress = 100; + } + + instance->pCallback(pkg_type, pkg_name, + event_type, event_state, progress, + PACKAGE_MANAGER_ERROR_NONE, + instance->pCallbackUserData); + + + return PACKAGE_MANAGER_ERROR_NONE; +} + +static package_info_h make_package_info_handle(const PackageProxy::PackageInfo& info) +{ + uid_t krate_uid; + + if (info.id.empty()) { + return NULL; + } + + try { + runtime::User pkgOwner(info.krate); + krate_uid = pkgOwner.getUid(); + } catch (runtime::Exception &e) { + return NULL; + } + + package_x* package = (package_x*)::calloc(1, sizeof(package_x)); + pkgmgr_pkginfo_x* pkginfo = (pkgmgr_pkginfo_x*)::calloc(1, sizeof(pkgmgr_pkginfo_x)); + package_info_s* packageinfo = (package_info_s*)::calloc(1, sizeof(package_info_s)); + + packageinfo->package = ::strdup(info.id.c_str()); + packageinfo->pkgmgr_pkginfo = pkginfo; + + pkginfo->uid = krate_uid; + pkginfo->locale = ::strdup(info.locale.c_str()); + pkginfo->pkg_info = package; + + package->for_all_users = ::strdup("false"); + package->package = ::strdup(info.id.c_str()); + package->version = ::strdup(info.version.c_str()); + package->removable = ::strdup(info.isRemovable? "true":"false"); + package->preload = ::strdup(info.isPreload? "true":"false"); + package->system = ::strdup(info.isSystem? "true":"false"); + package->type = ::strdup(info.type.c_str()); + package->mainapp_id = ::strdup(info.mainAppId.c_str()); + package->api_version = ::strdup(info.apiVersion.c_str()); + + icon_x* icon = (icon_x*)::calloc(1, sizeof(icon_x)); + icon->text = ::strdup(info.icon.c_str()); + icon->lang = ::strdup(info.locale.c_str()); + package->icon = ::g_list_append(NULL, icon); + + label_x* label = (label_x*)::calloc(1, sizeof(label_x)); + label->text = ::strdup(info.label.c_str()); + label->lang = ::strdup(info.locale.c_str()); + package->label = ::g_list_append(NULL, label); + + description_x* desc = (description_x*)::calloc(1, sizeof(description_x)); + desc->text = ::strdup(info.description.c_str()); + desc->lang = ::strdup(info.locale.c_str()); + package->description = ::g_list_append(NULL, desc); + + author_x* author = (author_x*)::calloc(1, sizeof(author_x)); + author->text = ::strdup(info.author.name.c_str()); + author->email = ::strdup(info.author.email.c_str()); + author->href = ::strdup(info.author.href.c_str()); + author->lang = ::strdup(info.locale.c_str()); + package->author = ::g_list_append(NULL, author); + + return reinterpret_cast(packageinfo); +} + +int krate_package_proxy_create(krate_manager_h manager, const char* name, krate_package_proxy_h *handle) +{ + RET_ON_FAILURE(manager, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(name, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + + krate_package_proxy_s* instance = new krate_package_proxy_s { + GetKrateContext(manager). + createKrateInterface(), + name, ::pkgmgr_client_new(PC_LISTENING), NULL, NULL + }; + + *handle = reinterpret_cast(instance); + return KRATE_ERROR_NONE; +} + +int krate_package_proxy_destroy(krate_package_proxy_h handle) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + + krate_package_proxy_s* instance = getInstance(handle); + + ::pkgmgr_client_free(instance->pNativeHandle); + + delete instance; + + return KRATE_ERROR_NONE; +} + +int krate_package_proxy_get_package_info(krate_package_proxy_h handle, const char* package_id, package_info_h* package_info) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(package_id, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(package_info, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + auto& proxy = instance->proxy; + const std::string& name = instance->krateName; + + const auto& info = proxy.getPackageInfo(name, package_id); + package_info_h ret = make_package_info_handle(info); + + if (ret == NULL) { + return KRATE_ERROR_INVALID_PARAMETER; + } + + *package_info = ret; + + return KRATE_ERROR_NONE; +} + +int krate_package_proxy_foreach_package_info(krate_package_proxy_h handle, package_manager_package_info_cb callback, void *user_data) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(callback, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + auto& proxy = instance->proxy; + const std::string& name = instance->krateName; + + for (const auto& pkgid : proxy.getPackageList(name)) { + package_info_h info_h = make_package_info_handle(proxy.getPackageInfo(name, pkgid)); + int ret = callback(info_h, user_data); + package_info_destroy(info_h); + if (!ret) { + break; + } + } + + return KRATE_ERROR_NONE; +} + +int krate_package_proxy_set_event_status(krate_package_proxy_h handle, int status_type) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + + int ret; + ret = pkgmgrinfo_client_set_status_type(instance->pNativeHandle, status_type); + + if (ret != PACKAGE_MANAGER_ERROR_NONE) + return KRATE_ERROR_INVALID_PARAMETER; + + return KRATE_ERROR_NONE; +} + +int krate_package_proxy_set_event_cb(krate_package_proxy_h handle, package_manager_event_cb callback, void *user_data) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(callback, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + + instance->pCallback = callback; + instance->pCallbackUserData = user_data; + + int ret; + ret = pkgmgr_client_listen_status(instance->pNativeHandle, packageEventHandler, handle); + + if (ret < 0) + return KRATE_ERROR_INVALID_PARAMETER; + + return KRATE_ERROR_NONE; +} + +int krate_package_proxy_unset_event_cb(krate_package_proxy_h handle) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + + int ret; + ret = pkgmgr_client_remove_listen_status(instance->pNativeHandle); + + if (ret < 0) + return KRATE_ERROR_INVALID_PARAMETER; + + return KRATE_ERROR_NONE; +} + +int krate_package_proxy_install(krate_package_proxy_h handle, const char* package_path) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(package_path, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + auto& proxy = instance->proxy; + const std::string& name = instance->krateName; + + return proxy.install(name, package_path); +} + +int krate_package_proxy_uninstall(krate_package_proxy_h handle, const char* package_id) +{ + RET_ON_FAILURE(handle, KRATE_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(package_id, KRATE_ERROR_INVALID_PARAMETER); + + auto instance = getInstance(handle); + auto& proxy = instance->proxy; + const std::string& name = instance->krateName; + + return proxy.uninstall(name, package_id); +} diff --git a/lib/krate/package-proxy.h b/lib/krate/package-proxy.h new file mode 100644 index 0000000..5dda76a --- /dev/null +++ b/lib/krate/package-proxy.h @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __CAPI_KRATE_PACKAGE_INFO_H__ +#define __CAPI_KRATE_PACKAGE_INFO_H__ + +#include +#include + +#include + +/** + * @file package-info.h + * @brief This file provides APIs to get the information of packages in the krate + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_KRATE_KRATE_PACKAGE_INFO_MODULE + * @{ + */ + +/** + * @brief The krate package proxy handle + * @since_tizen 3.0 + * @see krate_package_proxy_create() + * @see krate_package_proxy_destroy() + */ +typedef void* krate_package_proxy_h; + +/** + * @brief Acquires the krate package proxy handle. + * @details This API acquires krate package proxy handle required to call + * the krate package_manager APIs. + * @since_tizen 3.0 + * @param[in] manager The krate manager handle + * @param[in] name The krate name + * @param[out] handle The krate package proxy handle + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_CONNECTION_REFUSED Connection refused + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @see krate_manager_create() + * @see krate_package_proxy_destroy() + * @see get_last_result() + */ +KRATE_API int krate_package_proxy_create(krate_manager_h manager, const char* name, krate_package_proxy_h *handle); + +/** + * @brief Releases the krate package proxy handle. + * @details This API must be called if interaction with the krate package + * manager handle is no longer required. + * @since_tizen 3.0 + * @param[in] handle The krate package proxy handle + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @pre The handle must be created by krate_package_proxy_create() + * @see krate_package_proxy_create() + */ +KRATE_API int krate_package_proxy_destroy(krate_package_proxy_h handle); + +/** + * @brief Gets the package information for the given package in the krate. + * @details This API gets package information handle required to get + * information of the pacakge in the krate. + * @since_tizen 3.0 + * @param[in] handle The krate package proxy handle + * @param[in] pakcage_id The package ID + * @return Krate package information handle on success, otherwise NULL + * @remark The specific error code can be obtained by using the + * get_last_result() method. Error codes are described in + * exception section. + * @remark The handle should be destroyed using package_info_destroy(). + * @exception #KRATE_ERROR_NONE No error + * @exception #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #KRATE_ERROR_TIMED_OUT Time out + * @see krate_package_proxy_create() + * @see krate_package_proxy_destroy() + * @see package_manager_get_package_info() + * @see package_manager_destroy() + * @see get_last_result() + */ +KRATE_API int krate_package_proxy_get_package_info(krate_package_proxy_h handle, const char* pakcage_id, package_info_h* package_info); + +/** + * @brief Retrieves all the IDs of the installed package in the krate. + * @details This API calls package_manager_package_info_cb() once for + * each package information handle with traversing the installed + * package list in the krate. + * @since_tizen 3.0 + * @param[in] handle The krate package proxy handle + * @param[in] callback The iteration callback function + * @param[in] user_data The user data passed to the callback function + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The handle must be created by krate_package_proxy_create(). + * @see krate_package_proxy_create() + * @see krate_package_proxy_destroy() + * @see package_manager_foreach_package_info() + */ +KRATE_API int krate_package_proxy_foreach_package_info(krate_package_proxy_h handle, package_manager_package_info_cb callback, void *user_data); + +/** + * @brief Installs the package located at the given path into the krate. + * @details Administrator can use this API to install the package into the + * krate. + * @since_tizen 3.0 + * @param[in] handle The krate package proxy handle + * @param[in] name The krate name + * @param[in] package_path The absolute path to the package to be installed + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @retval #KRATE_ERROR_NO_SUCH_FILE No such package file + * @retval #KRATE_ERROR_PERMISSION_DENIED The application does not have + * the privilege to call this API or the caller is not the owner + * of the krate + * @pre The handle must be created by krate_package_proxy_create(). + * @pre The krate corresponding to the given name must be + * created before use of this API. + * @see krate_package_proxy_create() + * @see krate_package_proxy_destroy() + * @see krate_package_proxy_uninstall() + * @see package_manager_request_install() + */ +KRATE_API int krate_package_proxy_install(krate_package_proxy_h handle, const char* package_path); + +/** + * @brief Uinstalls the package with the given ID from the krate. + * @details Administrator can use this API to uninstall the package from the + * krate. + * @since_tizen 3.0 + * @param[in] handle The krate package proxy handle + * @param[in] name The krate name + * @param[in] pakcage_id The pakcage ID + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @retval #KRATE_ERROR_NO_DATA No such pacakge to unintall + * @retval #KRATE_ERROR_PERMISSION_DENIED The application does not have + * the privilege to call this API or the caller is not the owner + * of the krate + * @pre The handle must be created by krate_package_proxy_create(). + * @pre The krate corresponding to the given name must be + * created before use of this API. + * @see krate_package_proxy_create() + * @see krate_package_proxy_destroy() + * @see krate_package_proxy_install() + * @see package_manager_request_uninstall() + */ +KRATE_API int krate_package_proxy_uninstall(krate_package_proxy_h handle, const char* pakcage_id); + +/** + * @brief Sets the event status that presents the package has been + * installed, uninstalled or updated in the krate. + * @details This API sets the event status of the package for monitoring + * whether the package has been installed, uninstalled or updated. + * event status can be combined multiple status using OR operation. + * @since_tizen 3.0 + * @param[in] handle The krate package proxy handle + * @param[in] status_type The status of the package + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @pre The handle must be created by krate_package_proxy_create(). + * @pre the krate corresponding to the given name must be + * created before use of this api. + * @see krate_package_proxy_create() + * @see krate_package_proxy_destroy() + * @see krate_package_proxy_uninstall() + * @see krate_package_proxy_set_event_cb() + * @see krate_package_proxy_unset_event_cb() + * @see package_manager_set_event_status() + */ +KRATE_API int krate_package_proxy_set_event_status(krate_package_proxy_h handle, int status_type); + +/** + * @brief Registers a callback function for package event. + * @details This API sets a callback function to be invoked when the package + * has been installed, uninstalled or updated. + * @since_tizen 3.0 + * @param[in] handle the krate package proxy handle + * @param[in] callback The callback function to be registered + * @param[in] user_data The user data to be passed to the callback function + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @pre the handle must be created by krate_package_proxy_create(). + * @see krate_package_proxy_create() + * @see krate_package_proxy_destroy() + * @see krate_package_proxy_uninstall() + * @see krate_package_proxy_set_event_status() + * @see krate_package_proxy_unset_event_cb() + * @see package_manager_event_cb() + * @see package_manager_set_event_cb() + */ +KRATE_API int krate_package_proxy_set_event_cb(krate_package_proxy_h handle, package_manager_event_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @details This API unsets the callback funtion not to be invoked by + * package event status + * @since_tizen 3.0 + * @param[in] handle the krate package proxy handle + * @param[in] name the krate name + * @return #KRATE_ERROR_NONE on success, otherwise a negative value + * @retval #KRATE_ERROR_NONE Successful + * @retval #KRATE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #KRATE_ERROR_TIMED_OUT Time out + * @pre the handle must be created by krate_package_proxy_create(). + * created before use of this api. + * @see krate_package_proxy_create() + * @see krate_package_proxy_destroy() + * @see krate_package_proxy_uninstall() + * @see krate_package_proxy_set_event_status() + * @see krate_package_proxy_set_event_cb() + * @see package_manager_unset_event_cb() + */ +KRATE_API int krate_package_proxy_unset_event_cb(krate_package_proxy_h handle); + + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CAPI_KRATE_PACKAGE_INFO_H__ */ diff --git a/lib/manager.cpp b/lib/manager.cpp new file mode 100644 index 0000000..57a5264 --- /dev/null +++ b/lib/manager.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "rmi/manager.h" + +namespace Krate { + +Manager::Manager(KrateControlContext& ctx) : + context(ctx) +{ +} + +Manager::~Manager() +{ +} + +int Manager::createKrate(const std::string& name, const std::string& setupWizAppid) +{ + try { + return context->methodCall("Manager::createKrate", name, setupWizAppid); + } catch (runtime::Exception& e) { + return -1; + } +} + +int Manager::removeKrate(const std::string& name) +{ + try { + return context->methodCall("Manager::removeKrate", name); + } catch (runtime::Exception& e) { + return -1; + } +} + +int Manager::lockKrate(const std::string& name) +{ + try { + return context->methodCall("Manager::lockKrate", name); + } catch (runtime::Exception& e) { + return -1; + } +} + +int Manager::unlockKrate(const std::string& name) +{ + try { + return context->methodCall("Manager::unlockKrate", name); + } catch (runtime::Exception& e) { + return -1; + } +} + +int Manager::getKrateState(const std::string& name) +{ + try { + return context->methodCall("Manager::getKrateState", name); + } catch (runtime::Exception& e) { + return -1; + } +} + +std::vector Manager::getKrateList(int state) +{ + std::vector empty; + try { + return context->methodCall>("Manager::getKrateList", state); + } catch (runtime::Exception& e) { + return empty; + } +} + +int Manager::resetKratePassword(const std::string& name, const std::string& newPassword) +{ + try { + return context->methodCall("Manager::resetKratePassword", name, newPassword); + } catch (runtime::Exception& e) { + return -1; + } +} + +} // namespace Krate diff --git a/lib/package-proxy.cpp b/lib/package-proxy.cpp new file mode 100644 index 0000000..0a58e34 --- /dev/null +++ b/lib/package-proxy.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "rmi/package-proxy.h" + +namespace Krate { + +PackageProxy::PackageProxy(KrateControlContext& ctx) : + context(ctx) +{ +} + +PackageProxy::~PackageProxy() +{ +} + +PackageProxy::PackageInfo PackageProxy::getPackageInfo(const std::string& name, const std::string& pkgid) +{ + try { + return context->methodCall("PackageProxy::getPackageInfo", name, pkgid); + } catch (runtime::Exception& e) {} + return PackageProxy::PackageInfo(); +} + +std::vector PackageProxy::getPackageList(const std::string& krate) +{ + try { + return context->methodCall>("PackageProxy::getPackageList", krate); + } catch (runtime::Exception& e) {} + return std::vector();; +} + +int PackageProxy::install(const std::string& name, const std::string& pkgid) +{ + try { + return context->methodCall("PackageProxy::install", name, pkgid); + } catch (runtime::Exception& e) { + return -1; + } +} + +int PackageProxy::uninstall(const std::string& name, const std::string& pkgid) +{ + try { + return context->methodCall("PackageProxy::uninstall", name, pkgid); + } catch (runtime::Exception& e) { + return -1; + } +} + +} // namespace Krate diff --git a/module/CMakeLists.txt b/module/CMakeLists.txt index be7a884..ab4f5e3 100644 --- a/module/CMakeLists.txt +++ b/module/CMakeLists.txt @@ -1,7 +1,7 @@ # # Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved # -# Licensed under the Apache License, Version 2.0 (the "License"); +# 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 # @@ -18,10 +18,12 @@ FILE(GLOB PAM_SRCS krate.cpp krate-builder.cpp ) -SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack") +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack") -ADD_LIBRARY(pam_${PROJECT_NAME} MODULE ${PAM_SRCS}) -SET_TARGET_PROPERTIES(pam_${PROJECT_NAME} PROPERTIES PREFIX "" +SET(PAM_NAME pam_${PROJECT_NAME}) + +ADD_LIBRARY(${PAM_NAME} MODULE ${PAM_SRCS}) +SET_TARGET_PROPERTIES(${PAM_NAME} PROPERTIES PREFIX "" COMPILE_DEFINITIONS PID_FILE_PATH="${RUN_INSTALL_DIR}/krate" COMPILE_FLAGS "-fvisibility=hidden" ) @@ -36,16 +38,17 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(PAM DEFAULT_MSG PAM_LIBRARY PAM_INCLUDE_DIR) PKG_CHECK_MODULES(PAM_DEPS REQUIRED klay + libxml-2.0 ) INCLUDE_DIRECTORIES(${PAM_INCLUDE_DIR} ${PAM_DEPS_INCLUDE_DIRS}) -TARGET_LINK_LIBRARIES(pam_${PROJECT_NAME} ${PAM_LIBRARY} ${PAM_DEPS_LIBRARIES} pthread) +TARGET_LINK_LIBRARIES(${PAM_NAME} ${PAM_LIBRARY} ${PAM_DEPS_LIBRARIES} pthread) -TARGET_COMPILE_DEFINITIONS(pam_${PROJECT_NAME} PRIVATE - CONF_PATH="${CONF_INSTALL_DIR}" +TARGET_COMPILE_DEFINITIONS(${PAM_NAME} PRIVATE + CONF_PATH="${CONF_DIR}" ) CONFIGURE_FILE(pam.d/systemd-user.in pam.d/systemd-user-${PROJECT_NAME}) -INSTALL(TARGETS pam_${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/security) +INSTALL(TARGETS ${PAM_NAME} DESTINATION ${LIB_INSTALL_DIR}/security) INSTALL(FILES pam.d/systemd-user-${PROJECT_NAME} DESTINATION ${PAMD_DIR}) diff --git a/module/krate.cpp b/module/krate.cpp index 06fea56..84496cf 100644 --- a/module/krate.cpp +++ b/module/krate.cpp @@ -30,11 +30,9 @@ #include #include -#define KRATE_MANIFEST_DIR CONF_PATH "/krate/" - std::string buildKrateManifestPath(const std::string& name) { - return KRATE_MANIFEST_DIR + name + ".xml"; + return CONF_PATH "/" + name + ".xml"; } std::string getKrateName(pam_handle_t* handle) diff --git a/packaging/krate.spec b/packaging/krate.spec index a6e952e..e132b27 100644 --- a/packaging/krate.spec +++ b/packaging/krate.spec @@ -5,6 +5,8 @@ License: Apache-2.0 Source0: file://%{name}-%{version}.tar.gz Summary: Tizen Krate Manager Group: Security/Other +Requires: systemd +BuildRequires: pam-devel BuildRequires: gcc BuildRequires: cmake BuildRequires: gettext-tools @@ -17,13 +19,13 @@ BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(appsvc) BuildRequires: pkgconfig(libtzplatform-config) -BuildRequires: pkgconfig(security-privilege-manager) -BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(capi-system-system-settings) BuildRequires: pkgconfig(notification) BuildRequires: pkgconfig(key-manager) BuildRequires: pkgconfig(auth-fw-admin) +BuildRequires: pkgconfig(cynara-client) +BuildRequires: pkgconfig(cynara-session) +BuildRequires: pkgconfig(libgum) %description The krate package provides a daemon which is responsible for managing each of @@ -32,16 +34,19 @@ krates. %files %manifest krate.manifest %defattr(644,root,root,755) -#%attr(755,root,root) %{_bindir}/krate +%attr(755,root,root) %{_bindir}/krated %attr(700,root,root) %{_sbindir}/krate-volume-manager %{_unitdir}/krate.service -#%{_unitdir}/multi-user.target.wants/krate.service +%{_unitdir}/multi-user.target.wants/krate.service %attr(700,root,root) /etc/gumd/useradd.d/20_krate-add.post %attr(700,root,root) /etc/gumd/userdel.d/20_krate-remove.post %attr(644,root,root) %{TZ_SYS_RO_ICONS}/krate/indicator_icon.png %attr(644,root,root) %{TZ_SYS_RO_ICONS}/krate/notification_sub_icon.png %attr(700,root,root) %dir %{TZ_SYS_ETC}/krate %attr(600,root,root) %config %{TZ_SYS_ETC}/krate/owner.xml +%attr(700,root,root) %{_libdir}/security/pam_*.so +%attr(700,root,root) %{_sbindir}/krate-admin-cli +%config /etc/pam.d/* %prep %setup -q @@ -65,16 +70,20 @@ krates. -DSYSTEMD_UNIT_DIR=%{_unitdir} \ -DPAMD_DIR=/etc/pam.d \ -DCONF_DIR=%{TZ_SYS_ETC}/krate \ + -DICON_DIR="%{TZ_SYS_RO_ICONS}/krate" \ -DAPP_INSTALL_PREFIX="%{TZ_SYS_RO_APP}" \ - -DAPP_ICON_DIR_PREFIX="%{TZ_SYS_RO_ICONS}" \ -DAPP_SHARE_PACKAGES_DIR="%{TZ_SYS_RO_PACKAGES}" make %{?jobs:-j%jobs} %install %make_install -#mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants -#ln -s ../krate.service %{buildroot}/%{_unitdir}/multi-user.target.wants/krate.service +mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants +ln -s ../krate.service %{buildroot}/%{_unitdir}/multi-user.target.wants/krate.service + +%post +mv /etc/pam.d/systemd-user /etc/pam.d/systemd-user.keep +cp /etc/pam.d/systemd-user-krate /etc/pam.d/systemd-user %clean rm -rf %{buildroot} @@ -82,8 +91,8 @@ rm -rf %{buildroot} %preun %postun +mv /etc/pam.d/systemd-user.keep /etc/pam.d/systemd-user -%if 0 ## Krate Client Package ######################################################## %package -n libkrate Summary: Tizen Krate Client library @@ -91,7 +100,7 @@ Group: Development/Libraries BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(capi-appfw-package-manager) BuildRequires: pkgconfig(libtzplatform-config) -Requires: %{name} = %{version}-%{release} +#Requires: %{name} = %{version}-%{release} Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -125,48 +134,19 @@ developing the krate client program. %{_includedir}/krate %{_libdir}/pkgconfig/krate.pc -%endif - -## PAM Plugin Package ######################################################## -%package -n dpm-pam-krate -Summary: PAM Plugin for zone policy in device policy manager -Group: Development/Libraries -Requires: systemd -BuildRequires: pam-devel - -%description -n dpm-pam-krate -PAM Plugin for zone policy in device policy manager and CLI tool - -%post -n dpm-pam-krate -mv /etc/pam.d/systemd-user /etc/pam.d/systemd-user.keep -cp /etc/pam.d/systemd-user-zone /etc/pam.d/systemd-user - -%postun -n dpm-pam-krate -mv /etc/pam.d/systemd-user.keep /etc/pam.d/systemd-user - -%files -n dpm-pam-krate -%manifest krate.manifest -%defattr(600,root,root,700) -%attr(700,root,root) %{_libdir}/security/pam_*.so -#%attr(700,root,root) %{_sbindir}/zone-admin-cli -%config /etc/pam.d/* - -## Begin of mobile feature ################################################### -%if "%{profile}" == "mobile" - ## Krate Setup Wizard Package ################################################# %package -n org.tizen.krate-setup-wizard Summary: Tizen Krate setup wizard Interface Group: Security/Other +Requires: libkrate = %{version}-%{release} BuildRequires: pkgconfig(efl-extension) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(evas) BuildRequires: pkgconfig(notification) -BuildRequires: pkgconfig(zone) %description -n org.tizen.krate-setup-wizard -Tizen Krate setup wizard interface for zone +Tizen Krate setup wizard interface %define setup_home %{TZ_SYS_RO_APP}/org.tizen.krate-setup-wizard @@ -205,6 +185,7 @@ Tizen Krate launcher interface %package -n org.tizen.keyguard Summary: Tizen Krate keyguard Interface Group: Security/Other +Requires: libkrate = %{version}-%{release} BuildRequires: pkgconfig(efl-extension) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(capi-appfw-application) @@ -224,5 +205,3 @@ Tizen Krate keyguard interface %{keyguard_home}/bin/* %{keyguard_home}/res/* %{TZ_SYS_RO_PACKAGES}/org.tizen.keyguard.xml - -%endif diff --git a/rmi/app-proxy.h b/rmi/app-proxy.h new file mode 100644 index 0000000..927a8dc --- /dev/null +++ b/rmi/app-proxy.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __APP_PROXY_H__ +#define __APP_PROXY_H__ + +#include "context.h" + +namespace Krate { + +/** + * This class provides APIs to create/remove and manage names. + */ + +class AppProxy { +public: + AppProxy(KrateControlContext& ctxt); + ~AppProxy(); + + //application information + struct AppInfo { + std::string krate; + std::string id; + std::string locale; + std::string package; + std::string type; + std::string icon; + std::string label; + int componentType; + bool isNoDisplayed; + bool isTaskManaged; + + REFLECTABLE + ( + krate, id, locale, package, type, icon, label, + componentType, isNoDisplayed, isTaskManaged + ); + }; + + AppInfo getAppInfo(const std::string& name, const std::string& appid); + + int createIterator(const std::string& name); + AppInfo getIteratorValue(int iterator); + bool nextIterator(int iterator); + int destroyIterator(int iterator); + + //application bundle + struct Bundle { + std::string operation; + std::string uri; + std::string mime; + std::string category; + std::string appId; + struct Extra { + std::string key; + std::vector value; + REFLECTABLE(key, value); + }; + std::vector extraData; + + REFLECTABLE + ( + operation, uri, mime, category, appId, extraData + ); + }; + + int launch(const std::string& name, const Bundle& bundle); + int resume(const std::string& name, const std::string& appid); + int terminate(const std::string& name, const std::string& appid); + bool isRunning(const std::string& name, const std::string& appid); + +private: + KrateControlContext& context; +}; + +} // namespace Krate +#endif // __APP_PROXY_H__ diff --git a/rmi/manager.h b/rmi/manager.h new file mode 100644 index 0000000..53005f7 --- /dev/null +++ b/rmi/manager.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __MANAGER_H__ +#define __MANAGER_H__ + +#include "context.h" + +namespace Krate { + +class Manager { +public: + enum State { + Locked = 0x01, + Running = 0x02, + }; + + Manager(KrateControlContext& ctxt); + ~Manager(); + + int createKrate(const std::string& name, const std::string& manifest); + int removeKrate(const std::string& name); + int lockKrate(const std::string& name); + int unlockKrate(const std::string& name); + + int getKrateState(const std::string& name); + + std::vector getKrateList(int state); + + int resetKratePassword(const std::string& name, const std::string& newPassword); + +private: + KrateControlContext& context; +}; + +} // namespace Krate +#endif // __MANAGER_H__ diff --git a/rmi/package-proxy.h b/rmi/package-proxy.h new file mode 100644 index 0000000..300d609 --- /dev/null +++ b/rmi/package-proxy.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __PACKAGE_PROXY_H__ +#define __PACKAGE_PROXY_H__ + +#include "context.h" + +namespace Krate { + +/** + * This class provides APIs to control packages in the krates. + */ + +class PackageProxy { +public: + PackageProxy(KrateControlContext& ctxt); + ~PackageProxy(); + + //package information + struct PackageInfo { + std::string krate; + std::string id; + std::string locale; + std::string type; + std::string icon; + std::string label; + std::string description; + struct { + std::string name; + std::string email; + std::string href; + REFLECTABLE(name, email, href); + } author; + std::string version; + std::string apiVersion; + std::string mainAppId; + bool isSystem; + bool isRemovable; + bool isPreload; + + REFLECTABLE + ( + krate, id, locale, type, icon, label, description, author, + version, apiVersion, mainAppId, isSystem, isRemovable, isPreload + ); + }; + + PackageInfo getPackageInfo(const std::string& name, const std::string& pkgid); + std::vector getPackageList(const std::string& name); + + //package manager request + int install(const std::string& name, const std::string& pkgpath); + int uninstall(const std::string& name, const std::string& pkgid); + +private: + KrateControlContext& context; +}; + +} // namespace Krate +#endif // __PACKAGE_PROXY_H__ diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 48b71a3..942f7e0 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -13,16 +13,61 @@ # See the License for the specific language governing permissions and # limitations under the License. # +SET(SERVER_SRCS main.cpp + server.cpp + packman.cpp + launchpad.cpp + app-bundle.cpp + manager.cpp + app-proxy.cpp + package-proxy.cpp +) -SET(TARGET ${PROJECT_NAME}) +SET(DEPENDENCY klay + glib-2.0 + gio-2.0 + libxml-2.0 + bundle + aul + appsvc + pkgmgr + pkgmgr-info + libtzplatform-config + capi-system-system-settings + notification + libgum + cynara-client + cynara-session + auth-fw-admin +) + +SET(SERVER_NAME ${PROJECT_NAME}d) + +ADD_EXECUTABLE(${SERVER_NAME} ${SERVER_SRCS}) + +PKG_CHECK_MODULES(SERVER_DEPS REQUIRED ${DEPENDENCY}) + +INCLUDE_DIRECTORIES(SYSTEM ${SERVER_DEPS_INCLUDE_DIRS} ${KRATE_SERVER} ${PROJECT_SOURCE_DIR}) + +TARGET_LINK_LIBRARIES(${SERVER_NAME} ${SERVER_DEPS_LIBRARIES} pthread) + +SET_TARGET_PROPERTIES(${SERVER_NAME} PROPERTIES COMPILE_FLAGS "-fPIE") +SET_TARGET_PROPERTIES(${SERVER_NAME} PROPERTIES LINK_FLAGS "-pie") + +TARGET_COMPILE_DEFINITIONS(${SERVER_NAME} PRIVATE + CONF_PATH="${CONF_DIR}" + RUN_PATH="${RUN_DIR}" + ICON_PATH="${ICON_DIR}" +) CONFIGURE_FILE(systemd/krate.service.in systemd/krate.service) +INSTALL(TARGETS ${SERVER_NAME} DESTINATION ${BIN_DIR}) INSTALL(FILES systemd/krate.service DESTINATION ${SYSTEMD_UNIT_DIR}) INSTALL(FILES ${KRATE_TOOLS}/gumd-scripts/20_krate-add.post DESTINATION /etc/gumd/useradd.d) INSTALL(FILES ${KRATE_TOOLS}/gumd-scripts/20_krate-remove.post DESTINATION /etc/gumd/userdel.d) INSTALL(FILES ${KRATE_DATA}/DefaultManifest.xml DESTINATION ${CONF_DIR} RENAME owner.xml) -INSTALL(FILES ${KRATE_DATA}/indicator_icon.png DESTINATION ${APP_ICON_DIR_PREFIX}/krate) -INSTALL(FILES ${KRATE_DATA}/notification_sub_icon.png DESTINATION ${APP_ICON_DIR_PREFIX}/krate) +INSTALL(FILES ${KRATE_DATA}/indicator_icon.png DESTINATION ${ICON_DIR}) +INSTALL(FILES ${KRATE_DATA}/notification_sub_icon.png DESTINATION ${ICON_DIR}) diff --git a/server/app-bundle.cpp b/server/app-bundle.cpp new file mode 100644 index 0000000..518e36f --- /dev/null +++ b/server/app-bundle.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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-bundle.h" + +Bundle::Bundle() : + handle(nullptr) +{ + handle = ::bundle_create(); + if (handle == nullptr) { + throw runtime::Exception("Failed to create bundle"); + } +} + +Bundle::~Bundle() +{ + ::bundle_free(handle); +} + +void Bundle::addInternal(const std::string& key, const std::string& value) +{ + ::bundle_add_str(handle, key.c_str(), value.c_str()); +} + +void Bundle::addArrayInternal(const std::string& key, const std::vector& array) +{ + std::unique_ptr arrayptr(new const char*[array.size()]); + + int index = 0; + for (const std::string& data : array) { + arrayptr.get()[index++] = data.c_str(); + } + + ::bundle_add_str_array(handle, key.c_str(), arrayptr.get(), array.size()); +} diff --git a/server/app-bundle.h b/server/app-bundle.h new file mode 100644 index 0000000..9ce75ee --- /dev/null +++ b/server/app-bundle.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __APP_BUNDLE_H__ +#define __APP_BUNDLE_H__ + +#include +#include + +#include + +class Bundle { +public: + Bundle(); + ~Bundle(); + + template + void add(const std::string& key, const std::vector& value) + { + addArrayInternal(key, value); + } + + template + void add(const std::string& key, const T& value) + { + addInternal(key, value); + } + + bundle* get() const + { + return handle; + } + +private: + void addInternal(const std::string& key, const std::string& value); + void addArrayInternal(const std::string& key, const std::vector& array); + +private: + bundle* handle; +}; + +#endif //__APP_BUNDLE_H__ diff --git a/server/app-proxy.cpp b/server/app-proxy.cpp new file mode 100644 index 0000000..38b6e16 --- /dev/null +++ b/server/app-proxy.cpp @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +#include +#include +#include + +#include "packman.h" +#include "launchpad.h" + +#include "rmi/app-proxy.h" + +namespace Krate { + +namespace { + +struct IteratorData { + std::string krate; + std::vector list; + unsigned int current; +}; + +std::unordered_map iteratorMap; +int newIteratorId = 0; + +} // namespace + +AppProxy::AppProxy(KrateControlContext& ctx) : + context(ctx) +{ + context.registerParametricMethod(this, "", (AppProxy::AppInfo)(AppProxy::getAppInfo)(std::string, std::string)); + + context.registerParametricMethod(this, "", (int)(AppProxy::createIterator)(std::string)); + context.registerParametricMethod(this, "", (AppProxy::AppInfo)(AppProxy::getIteratorValue)(int)); + context.registerParametricMethod(this, "", (bool)(AppProxy::nextIterator)(int)); + context.registerParametricMethod(this, "", (int)(AppProxy::destroyIterator)(int)); + + context.registerParametricMethod(this, "", (int)(AppProxy::launch)(std::string, AppProxy::Bundle)); + context.registerParametricMethod(this, "", (int)(AppProxy::resume)(std::string, std::string)); + context.registerParametricMethod(this, "", (int)(AppProxy::terminate)(std::string, std::string)); + context.registerParametricMethod(this, "", (int)(AppProxy::isRunning)(std::string, std::string)); +} + +AppProxy::~AppProxy() +{ +} + +AppProxy::AppInfo AppProxy::getAppInfo(const std::string& name, const std::string& appid) +{ + AppInfo appInfo; + + try { + runtime::User user(name); + ApplicationInfo appinfo(appid, user.getUid()); + char* locale; + + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale); + if (locale == NULL) { + appInfo.locale = "No locale"; + } else { + appInfo.locale = locale; + free(locale); + } + + appInfo.krate = name; + appInfo.id = appid; + appInfo.package = appinfo.getPackage(); + appInfo.type = appinfo.getType(); + appInfo.icon = appinfo.getIcon(); + appInfo.label = appinfo.getLabel(); + appInfo.componentType = appinfo.getComponentType(); + appInfo.isNoDisplayed = appinfo.isNoDisplayed(); + appInfo.isTaskManaged = appinfo.isTaskManaged(); + } catch (runtime::Exception& e) { + ERROR("Failed to retrieve application info installed in the krate: " + appid); + } + + return appInfo; +} + +int AppProxy::createIterator(const std::string& name) +{ + int iteratorId = -1; + try { + PackageManager& packman = PackageManager::instance(); + runtime::User user(name); + IteratorData data; + + iteratorId = newIteratorId; + + data.krate = name; + data.list = packman.getAppList(user.getUid()); + data.current = 0; + + iteratorMap.insert(std::make_pair(iteratorId, data)); + + if (++newIteratorId < 0) { + newIteratorId = 0; + } + } catch (runtime::Exception& e) { + ERROR("Failed to retrieve package info installed in the krate"); + } + return iteratorId; +} + +AppProxy::AppInfo AppProxy::getIteratorValue(int iterator) +{ + AppInfo appInfo; + + auto it = iteratorMap.find(iterator); + if (it == iteratorMap.end()) { + return appInfo; + } + if (it->second.current >= it->second.list.size()) { + return appInfo; + } + + const ApplicationInfo& appinfo = it->second.list.at(it->second.current); + char* locale; + + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale); + if (locale == NULL) { + appInfo.locale = "No locale"; + } else { + appInfo.locale = locale; + free(locale); + } + + appInfo.krate = it->second.krate; + appInfo.id = appinfo.getId(); + appInfo.package = appinfo.getPackage(); + appInfo.type = appinfo.getType(); + appInfo.icon = appinfo.getIcon(); + appInfo.label = appinfo.getLabel(); + appInfo.componentType = appinfo.getComponentType(); + appInfo.isNoDisplayed = appinfo.isNoDisplayed(); + appInfo.isTaskManaged = appinfo.isTaskManaged(); + + return appInfo; +} + +bool AppProxy::nextIterator(int iterator) +{ + auto it = iteratorMap.find(iterator); + if (it != iteratorMap.end()) { + if (++it->second.current < it->second.list.size()) { + return true; + } + } + return false; +} + +int AppProxy::destroyIterator(int iterator) +{ + auto it = iteratorMap.find(iterator); + if (it != iteratorMap.end()) { + iteratorMap.erase(it); + return 0; + } + return -1; +} + +int AppProxy::launch(const std::string& name, const AppProxy::Bundle& bundle) +{ + try { + runtime::User user(name); + ::Bundle b; + + if (!bundle.operation.empty()) { + b.add("__APP_SVC_OP_TYPE__", bundle.operation); + } + if (!bundle.uri.empty()) { + b.add("__APP_SVC_URI__", bundle.uri); + } + if (!bundle.mime.empty()) { + b.add("__APP_SVC_MIME__", bundle.mime); + } + if (!bundle.category.empty()) { + b.add("__APP_SVC_CATEGORY__", bundle.category); + } + + for (Bundle::Extra extra : bundle.extraData) { + if (extra.value.size() > 1) { + b.add(extra.key, extra.value); + } else if (extra.value.size() == 1) { + b.add(extra.key, extra.value.at(0)); + } + } + + Launchpad launchpad(user.getUid()); + launchpad.launch(bundle.appId, b); + } catch (runtime::Exception& e) { + ERROR("Failed to launch app in the krate"); + return -1; + } + return 0; +} + +int AppProxy::resume(const std::string& name, const std::string& appid) +{ + try { + runtime::User user(name); + Launchpad launchpad(user.getUid()); + launchpad.resume(appid); + } catch (runtime::Exception& e) { + ERROR("Failed to terminate app in the krate"); + return -1; + } + return 0; +} + +int AppProxy::terminate(const std::string& name, const std::string& appid) +{ + try { + runtime::User user(name); + Launchpad launchpad(user.getUid()); + launchpad.terminate(appid); + } catch (runtime::Exception& e) { + ERROR("Failed to terminate app in the krate"); + return -1; + } + return 0; +} + +bool AppProxy::isRunning(const std::string& name, const std::string& appid) +{ + try { + runtime::User user(name); + Launchpad launchpad(user.getUid()); + return launchpad.isRunning(appid); + } catch (runtime::Exception& e) { + ERROR("Failed to get app running state in the krate"); + } + return false; +} + +} // namespace Krate diff --git a/server/context.h b/server/context.h new file mode 100644 index 0000000..ab771d9 --- /dev/null +++ b/server/context.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __KRATE_CONTEXT_H__ +#define __KRATE_CONTEXT_H__ + +#include "server.h" + +using KrateControlContext = Server; + +#endif //__KRATE_CONTEXT_H__ diff --git a/server/launchpad.cpp b/server/launchpad.cpp new file mode 100644 index 0000000..d0a1dbf --- /dev/null +++ b/server/launchpad.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +#include +#include +#include + +#include "launchpad.h" + +Launchpad::Launchpad(const uid_t uid) : + user(uid) +{ + if (user == 0) { + throw runtime::Exception("No logined user for launching app"); + } +} + +bool Launchpad::isRunning(const std::string& appid) +{ + return ::aul_app_is_running_for_uid(appid.c_str(), user); +} + +void Launchpad::launch(const std::string& appid) +{ + launch(appid, Bundle()); +} + +void Launchpad::launch(const std::string& appid, const Bundle& bundle) +{ + if (::aul_launch_app_for_uid(appid.c_str(), bundle.get(), user) < 0) { + throw runtime::Exception("Failed to launch app " + appid); + } +} + +void Launchpad::resume(const std::string& appid) +{ + if (::aul_resume_app_for_uid(appid.c_str(), user) < 0) { + throw runtime::Exception("Failed to resume app " + appid); + } +} + +void Launchpad::terminate(const std::string& appid) +{ + int pid = ::aul_app_get_pid_for_uid(appid.c_str(), user); + if (pid > 0) { + if (::aul_terminate_pid_for_uid(pid, user) < 0) { + WARN("Failed to terminate app PID=" + std::to_string(pid)); + ::kill(pid, SIGKILL); + } + } +} diff --git a/server/launchpad.h b/server/launchpad.h new file mode 100644 index 0000000..c3120ed --- /dev/null +++ b/server/launchpad.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __LAUNCHPAD_H__ +#define __LAUNCHPAD_H__ + +#include + +#include "app-bundle.h" + +class Launchpad { +public: + Launchpad(const uid_t uid = 0); + Launchpad(const Launchpad&) = delete; + Launchpad(Launchpad&&) = delete; + + void launch(const std::string& appid); + void launch(const std::string& appid, const Bundle& bundle); + void resume(const std::string& appid); + bool isRunning(const std::string& appid); + void terminate(const std::string& appid); + +private: + uid_t user; +}; + +#endif //__LAUNCHPAD_H__ diff --git a/server/main.cpp b/server/main.cpp new file mode 100644 index 0000000..448df58 --- /dev/null +++ b/server/main.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 +#include +#include +#include +#include + +#include +#include + +#include "server.h" + +void signalHandler(int signum) +{ + exit(0); +} + +int main(int argc, char *argv[]) +{ + ::signal(SIGINT, signalHandler); + + ::umask(0); + + try { + Server server; + server.run(); + } catch (std::exception &e) { + std::cerr << e.what() << std::endl; + return 1; + } + + return 0; +} diff --git a/server/manager.cpp b/server/manager.cpp new file mode 100644 index 0000000..5d6bc03 --- /dev/null +++ b/server/manager.cpp @@ -0,0 +1,701 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "packman.h" +#include "launchpad.h" + +#include "rmi/manager.h" + +#define KRATE_DELEGATOR_APP "org.tizen.keyguard" +#define NOTIFICATION_SUB_ICON_PATH ICON_PATH "/notification_sub_icon.png" + +namespace Krate { + +namespace { + +const std::vector defaultGroups = { + "audio", + "video", + "display", + "log" +}; + +const std::vector unitsToMask = { + "starter.service", + "scim.service" +}; + +const std::string KRATE_SKEL_PATH = "/etc/skel"; +const std::string KRATE_CREATE_HOOK_PATH = "/etc/gumd/useradd.d"; +const std::string KRATE_REMOVE_HOOK_PATH = "/etc/gumd/userdel.d"; + +const std::string KRATE_DEFAULT_OWNER = "owner"; + +const std::string KRATE_GROUP = "users"; + +std::list createdKrateList; +static std::atomic isKrateForeground(false); + +std::unordered_map notiHandleMap; + +inline void maskUserServices(const runtime::User& user) +{ + ::tzplatform_set_user(user.getUid()); + std::string pivot(::tzplatform_getenv(TZ_USER_HOME)); + ::tzplatform_reset_user(); + + runtime::File unitbase(pivot + "/.config/systemd/user"); + unitbase.makeDirectory(true); + unitbase.chmod(S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); + + for (const std::string& unit : unitsToMask) { + std::string target = unitbase.getPath() + "/" + unit; + if (::symlink("/dev/null", target.c_str()) == -1) { + throw runtime::Exception(runtime::GetSystemErrorMessage()); + } + } +} + +inline void setKrateState(uid_t id, int state) +{ + dbus::Connection& systemDBus = dbus::Connection::getSystem(); + systemDBus.methodcall("org.freedesktop.login1", + "/org/freedesktop/login1", + "org.freedesktop.login1.Manager", + "SetUserLinger", + -1, "", "(ubb)", id, state, 1); +} + +inline const std::string convertPathForOwner(const std::string& path, const runtime::User& user, const runtime::User& owner) +{ + ::tzplatform_set_user(owner.getUid()); + std::string ownerHome(::tzplatform_getenv(TZ_USER_HOME)); + ::tzplatform_reset_user(); + ownerHome += "/.krate"; + + ::tzplatform_set_user(user.getUid()); + std::string userHome(::tzplatform_getenv(TZ_USER_HOME)); + ::tzplatform_reset_user(); + + std::string userHomeForOwner(ownerHome + "/" + user.getName()); + + std::string convertedPath(path); + + if (convertedPath.compare(0, userHome.size(), userHome) == 0) { + convertedPath.replace(0, userHome.size(), userHomeForOwner); + } + + return convertedPath; +} + +inline void prepareFileForOwner(const std::string path, const runtime::User& pkgUser, const runtime::User& owner) +{ + std::string pathLink = convertPathForOwner(path, pkgUser, owner); + + if (path != pathLink) { + runtime::File linkFile(pathLink); + linkFile.makeBaseDirectory(pkgUser.getUid(), pkgUser.getGid()); + if (linkFile.exists()) { + linkFile.remove(); + } + + int ret = ::link(path.c_str(), pathLink.c_str()); + if (ret != 0) { + //TODO: copy the icon instead of linking + throw runtime::Exception("Failed to link from " + path + + " to " + pathLink); + } + } +} + +int packageEventHandler(uid_t target_uid, int req_id, + const char *pkg_type, const char *pkgid, + const char *key, const char *val, + const void *pmsg, void *data) +{ + static std::string type; + std::string keystr = key; + + if (target_uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) { + return 0; + } + + std::transform(keystr.begin(), keystr.end(), keystr.begin(), ::tolower); + if (keystr == "start") { + type = val; + std::transform(type.begin(), type.end(), type.begin(), ::tolower); + return 0; + } else if (keystr != "end" && keystr != "ok") { + return 0; + } + + try { + runtime::User owner(KRATE_DEFAULT_OWNER), pkgUser(target_uid); + + if (type == "install" || type == "update") { + PackageInfo pkg(pkgid, pkgUser.getUid()); + std::string icon = pkg.getIcon(); + prepareFileForOwner(icon, pkgUser, owner); + + for (const ApplicationInfo& app : pkg.getAppList()) { + std::string icon = app.getIcon(); + prepareFileForOwner(icon, pkgUser, owner); + } + } else { + ::tzplatform_set_user(pkgUser.getUid()); + std::string pkgPath(::tzplatform_getenv(TZ_USER_APP)); + pkgPath = pkgPath + "/" + pkgid; + ::tzplatform_reset_user(); + + runtime::File pkgDirForOwner(convertPathForOwner(pkgPath, pkgUser, owner)); + pkgDirForOwner.remove(true); + } + } catch (runtime::Exception &e) { + ERROR(e.what()); + } + + return 0; +} + +void initializeCreatedKrateList() { + try { + runtime::DirectoryIterator iter(CONF_PATH "/"), end; + + while (iter != end) { + const std::string& file = iter->getName(); + const std::string& name(file.substr(0, file.rfind(".xml"))); + createdKrateList.push_back(name); + ++iter; + } + } catch (runtime::Exception& e) {} +} + +#define NT_TITLE NOTIFICATION_TEXT_TYPE_TITLE +#define NT_CONTENT NOTIFICATION_TEXT_TYPE_CONTENT +#define NT_ICON NOTIFICATION_IMAGE_TYPE_ICON +#define NT_INDICATOR NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR +#define NT_NONE NOTIFICATION_VARIABLE_TYPE_NONE +#define NT_EVENT NOTIFICATION_LY_ONGOING_PROGRESS +#define NT_APP NOTIFICATION_DISPLAY_APP_INDICATOR + +#define NT_ICON_PATH ICON_PATH "/indicator_icon.png" +#define NT_TEXT "Container Mode" +#define NT_APPINFO "Krate Application" + +#define NT_ERROR_NONE NOTIFICATION_ERROR_NONE + +void krateProcessCallback(GDBusConnection *connection, + const gchar *sender, const gchar *objectPath, + const gchar *interface, const gchar *signalName, + GVariant *params, gpointer userData) +{ + static runtime::User owner(KRATE_DEFAULT_OWNER); + int pid, status; + +// notification_h noti = reinterpret_cast(userData); + + g_variant_get(params, "(ii)", &status, &pid); + + if (status != 5) { + return; + } + + struct stat st; + std::string proc("/proc/" + std::to_string(pid)); + if (::stat(proc.c_str(), &st) != 0) { + return; + } + + // this will have been commented until notification_delete_for_uid can work + /* + if (owner.getUid() != st.st_uid) { + if (!isKrateForeground) { + notification_set_text(noti, NT_CONTENT, NT_APPINFO, NULL, NT_NONE); + notification_post_for_uid(noti, owner.getUid()); + isKrateForeground = true; + } + } else { + if (isKrateForeground) { + notification_delete_for_uid(noti, owner.getUid()); + isKrateForeground = false; + } + }*/ +} + +notification_h createNotification() +{ + notification_h noti = notification_create(NOTIFICATION_TYPE_ONGOING); + if (noti == NULL) { + return NULL; + } + + if (notification_set_text(noti, NT_TITLE, NT_TEXT, NULL, NT_NONE) != NT_ERROR_NONE) { + notification_free(noti); + return NULL; + } + if (notification_set_image(noti, NT_ICON, NT_ICON_PATH) != NT_ERROR_NONE) { + notification_free(noti); + return NULL; + } + + if (notification_set_image(noti, NT_INDICATOR, NT_ICON_PATH) != NT_ERROR_NONE) { + notification_free(noti); + return NULL; + } + + if (notification_set_layout(noti, NT_EVENT) != NT_ERROR_NONE) { + notification_free(noti); + return NULL; + } + + if (notification_set_display_applist(noti, NT_APP) != NT_ERROR_NONE) { + notification_free(noti); + return NULL; + } + + return noti; +} + +void krateProcessMonitor() +{ + GError *error = NULL; + GDBusConnection* connection; + connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); + if (connection == NULL) { + ERROR("GBus Connection failed"); + g_error_free(error); + return; + } + + notification_h noti = createNotification(); + if (noti == NULL) { + ERROR("Failed to created notification"); + return; + } + + g_dbus_connection_signal_subscribe(connection, + NULL, + "org.tizen.resourced.process", + "ProcStatus", + "/Org/Tizen/ResourceD/Process", + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + krateProcessCallback, + reinterpret_cast(noti), + NULL); +} + +void notiProxyInsert(const runtime::User& owner, const runtime::User& user, int privId, notification_h noti) +{ + std::string krateLauncherUri; + notification_h newNoti; + app_control_h appControl; + char* pkgId; + + notification_clone(noti, &newNoti); + + notification_get_pkgname(noti, &pkgId); + PackageInfo pkg(pkgId, user.getUid()); + notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON, pkg.getIcon().c_str()); + notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON_SUB, NOTIFICATION_SUB_ICON_PATH); + + notification_get_launch_option(newNoti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, (void *)&appControl); + if (appControl != NULL) { + char* appId = NULL, *uri = NULL; + + app_control_get_app_id(appControl, &appId); + if (appId == NULL) { + appId = strdup(""); + } + + krateLauncherUri = "krate://enter/" + user.getName() + "/" + appId; + + app_control_get_uri(appControl, &uri); + if (uri != NULL) { + krateLauncherUri += "?uri="; + krateLauncherUri += uri; + free(uri); + } + + free(appId); + app_control_set_app_id(appControl, KRATE_DELEGATOR_APP); + app_control_set_uri(appControl, krateLauncherUri.c_str()); + notification_set_launch_option(newNoti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl); + } + + notification_post_for_uid(newNoti, owner.getUid()); + notiHandleMap.insert(std::make_pair(privId, newNoti)); +} + +void notiProxyDelete(const runtime::User& owner, int privId) +{ + std::unordered_map::iterator it; + + it = notiHandleMap.find(privId); + if (it == notiHandleMap.end()) { + return; + } + notification_delete_for_uid(it->second, owner.getUid()); + notification_free(it->second); + notiHandleMap.erase(it); +} + +void notiProxyUpdate(const runtime::User& owner, const runtime::User& user, int privId, notification_h noti) { + std::unordered_map::iterator it; + double progress; + char *str; + + it = notiHandleMap.find(privId); + if (it == notiHandleMap.end()) { + return; + } + + notification_image_type_e imageTypes[] = { + NOTIFICATION_IMAGE_TYPE_ICON, + NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, + NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, + NOTIFICATION_IMAGE_TYPE_THUMBNAIL, + NOTIFICATION_IMAGE_TYPE_THUMBNAIL_FOR_LOCK, + NOTIFICATION_IMAGE_TYPE_ICON_SUB, + NOTIFICATION_IMAGE_TYPE_BACKGROUND, + NOTIFICATION_IMAGE_TYPE_LIST_1, + NOTIFICATION_IMAGE_TYPE_LIST_2, + NOTIFICATION_IMAGE_TYPE_LIST_3, + NOTIFICATION_IMAGE_TYPE_LIST_4, + NOTIFICATION_IMAGE_TYPE_LIST_5, + NOTIFICATION_IMAGE_TYPE_BUTTON_1, + NOTIFICATION_IMAGE_TYPE_BUTTON_2, + NOTIFICATION_IMAGE_TYPE_BUTTON_3, + NOTIFICATION_IMAGE_TYPE_BUTTON_4, + NOTIFICATION_IMAGE_TYPE_BUTTON_5, + NOTIFICATION_IMAGE_TYPE_BUTTON_6 + }; + + for (notification_image_type_e type : imageTypes) { + notification_get_image(noti, type, &str); + notification_set_image(it->second, type, str); + } + + notification_text_type_e textTypes[] = { + NOTIFICATION_TEXT_TYPE_TITLE, + NOTIFICATION_TEXT_TYPE_CONTENT, + NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, + NOTIFICATION_TEXT_TYPE_EVENT_COUNT, + NOTIFICATION_TEXT_TYPE_INFO_1, + NOTIFICATION_TEXT_TYPE_INFO_SUB_1, + NOTIFICATION_TEXT_TYPE_INFO_2, + NOTIFICATION_TEXT_TYPE_INFO_SUB_2, + NOTIFICATION_TEXT_TYPE_INFO_3, + NOTIFICATION_TEXT_TYPE_INFO_SUB_3, + NOTIFICATION_TEXT_TYPE_GROUP_TITLE, + NOTIFICATION_TEXT_TYPE_GROUP_CONTENT, + NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, + NOTIFICATION_TEXT_TYPE_BUTTON_1, + NOTIFICATION_TEXT_TYPE_BUTTON_2, + NOTIFICATION_TEXT_TYPE_BUTTON_3, + NOTIFICATION_TEXT_TYPE_BUTTON_4, + NOTIFICATION_TEXT_TYPE_BUTTON_5, + NOTIFICATION_TEXT_TYPE_BUTTON_6, + }; + + for (notification_text_type_e type : textTypes) { + notification_get_text(noti, type, &str); + notification_set_text(it->second, type, str, NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + } + + notification_get_size(noti, &progress); + notification_set_size(it->second, progress); + + notification_get_progress(noti, &progress); + notification_set_progress(it->second, progress); + + notification_update_for_uid(it->second, owner.getUid()); +} + +void notiProxyCallback(void *data, notification_type_e type, notification_op *op_list, int num_op) +{ + static runtime::User owner(KRATE_DEFAULT_OWNER); + runtime::User user(*reinterpret_cast(data)); + + if (user.getName() == owner.getName()) { + // TODO : should remove noti in the krate when related-krate is removed + // This will be imlemented when notification bug is fixed + return; + } + + for (int i = 0; i < num_op; i++) { + notification_h noti = NULL; + int opType, privId; + + notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_TYPE, &opType); + notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_PRIV_ID, &privId); + + switch (opType) { + case NOTIFICATION_OP_INSERT: + notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_NOTI, ¬i); + notiProxyInsert(owner, user, privId, noti); + break; + case NOTIFICATION_OP_DELETE: + notiProxyDelete(owner, privId); + break; + case NOTIFICATION_OP_UPDATE: + notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_NOTI, ¬i); + notiProxyUpdate(owner, user, privId, noti); + break; + } + } +} + +} // namespace + +Manager::Manager(KrateControlContext& ctx) : + context(ctx) +{ + context.registerParametricMethod(this, "", (int)(Manager::createKrate)(std::string, std::string)); + context.registerParametricMethod(this, "", (int)(Manager::removeKrate)(std::string)); + context.registerParametricMethod(this, "", (int)(Manager::lockKrate)(std::string)); + context.registerParametricMethod(this, "", (int)(Manager::unlockKrate)(std::string)); + context.registerParametricMethod(this, "", (int)(Manager::getKrateState)(std::string)); + context.registerParametricMethod(this, "", (std::vector)(Manager::getKrateList)(int)); + context.registerParametricMethod(this, "", (int)(Manager::resetKratePassword)(std::string, std::string)); + + context.createNotification("Manager::created"); + context.createNotification("Manager::removed"); + + PackageManager& packageManager = PackageManager::instance(); + packageManager.setEventCallback(packageEventHandler, this); + + krateProcessMonitor(); + + initializeCreatedKrateList(); + for (std::string& name : createdKrateList) { + runtime::User krate(name); + notification_register_detailed_changed_cb_for_uid(notiProxyCallback, &name, krate.getUid()); + } +} + +Manager::~Manager() +{ +} + +int Manager::createKrate(const std::string& name, const std::string& manifest) +{ + auto provisioningWorker = [name, manifest, this]() { + std::unique_ptr manifestFile; + + try { + //create krate user by gumd + GumUser* guser = NULL; + while (guser == NULL) { + guser = gum_user_create_sync(FALSE); + } + g_object_set(G_OBJECT(guser), "username", name.c_str(), + "usertype", GUM_USERTYPE_SECURITY, NULL); + gboolean ret = gum_user_add_sync(guser); + g_object_unref(guser); + + if (!ret) { + throw runtime::Exception("Failed to remove user (" + name + ") by gumd"); + } + + runtime::User user(name); + + maskUserServices(user); + + manifestFile.reset(xml::Parser::parseString(manifest)); + manifestFile->write(CONF_PATH "/" + name + ".xml", "UTF-8", true); + + //TODO: write container owner info + + //unlock the user + setKrateState(user.getUid(), 1); + + //wait for launchpad in the krate + sleep(1); + + auto it = createdKrateList.insert(createdKrateList.end(), name); + notification_register_detailed_changed_cb_for_uid(notiProxyCallback, &(*it), user.getUid()); + context.notify("Manager::created", name, ""); + } catch (runtime::Exception& e) { + ERROR(e.what()); + context.notify("Manager::created", name, "Error"); + } + }; + + std::thread asyncWork(provisioningWorker); + asyncWork.detach(); + + return 0; +} + +int Manager::removeKrate(const std::string& name) +{ + if (lockKrate(name) != 0) { + return -1; + } + + auto remove = [name, this] { + //wait for krate session close + sleep(1); + + try { + runtime::User user(name); + + //umount TZ_USER_CONTENT + ::tzplatform_set_user(user.getUid()); + ::umount2(::tzplatform_getenv(TZ_USER_CONTENT), MNT_FORCE); + ::tzplatform_reset_user(); + + //remove krate user + GumUser* guser = NULL; + while (guser == NULL) { + guser = gum_user_get_sync(user.getUid(), FALSE); + } + gboolean ret = gum_user_delete_sync(guser, TRUE); + g_object_unref(guser); + + if (!ret) { + throw runtime::Exception("Failed to remove user " + name + "(" + std::to_string(user.getUid()) + ") by gumd"); + } + + auto it = createdKrateList.begin(); + for (; it != createdKrateList.end(); it++) { + if (*it == name) { + break; + } + } + createdKrateList.erase(it); + + notification_unregister_detailed_changed_cb_for_uid(notiProxyCallback, NULL, user.getUid()); + context.notify("Manager::removed", name, ""); + } catch (runtime::Exception& e) { + ERROR(e.what()); + context.notify("Manager::removed", name, "Error"); + return; + } + }; + + std::thread asyncWork(remove); + asyncWork.detach(); + + return 0; +} + +int Manager::lockKrate(const std::string& name) +{ + try { + runtime::User user(name); + setKrateState(user.getUid(), 0); + } catch (runtime::Exception& e) { + ERROR(e.what()); + return -1; + } + + return 0; +} + +int Manager::unlockKrate(const std::string& name) +{ + try { + runtime::User user(name); + setKrateState(user.getUid(), 1); + } catch (runtime::Exception& e) { + ERROR(e.what()); + return -1; + } + + return 0; +} + +int Manager::getKrateState(const std::string& name) +{ + auto it = std::find(createdKrateList.begin(), createdKrateList.end(), name); + if (it == createdKrateList.end()) { + return 0; + } + + try { + runtime::User user(name); + try { + dbus::Connection& systemDBus = dbus::Connection::getSystem(); + const dbus::Variant& var = systemDBus.methodcall + ("org.freedesktop.login1", + "/org/freedesktop/login1", + "org.freedesktop.login1.Manager", + "GetUser", + -1, "(o)", "(u)", user.getUid()); + return Manager::State::Running; + } catch (runtime::Exception& e) { + return Manager::State::Locked; + } + } catch (runtime::Exception& e) { + ERROR(e.what()); + return 0; + } + + return 0; +} + +std::vector Manager::getKrateList(int state) +{ + std::vector list; + + for (const std::string& name : createdKrateList) { + if (getKrateState(name) & state) { + list.push_back(name); + } + } + return list; +} + +int Manager::resetKratePassword(const std::string& name, const std::string& newPassword) +{ + try { + runtime::User user(name); + int ret = auth_passwd_reset_passwd(AUTH_PWD_NORMAL, user.getUid(), newPassword.c_str()); + if (ret != AUTH_PASSWD_API_SUCCESS) { + throw runtime::Exception("Failed to reset password for " + name); + } + } catch (runtime::Exception& e) { + ERROR(e.what()); + return -1; + } + + return 0; +} + +} // namespace Krate diff --git a/server/package-proxy.cpp b/server/package-proxy.cpp new file mode 100644 index 0000000..44513d4 --- /dev/null +++ b/server/package-proxy.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 +#include +#include + +#include "packman.h" + +#include "rmi/package-proxy.h" + +namespace Krate { + +PackageProxy::PackageProxy(KrateControlContext& ctx) : + context(ctx) +{ + context.registerParametricMethod(this, "", (PackageProxy::PackageInfo)(PackageProxy::getPackageInfo)(std::string, std::string)); + context.registerParametricMethod(this, "", (std::vector)(PackageProxy::getPackageList)(std::string)); + + context.registerParametricMethod(this, "", (int)(PackageProxy::install)(std::string, std::string)); + context.registerParametricMethod(this, "", (int)(PackageProxy::uninstall)(std::string, std::string)); +} + +PackageProxy::~PackageProxy() +{ +} + +PackageProxy::PackageInfo PackageProxy::getPackageInfo(const std::string& name, const std::string& pkgid) +{ + PackageProxy::PackageInfo package; + char* locale = NULL; + + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale); + if (locale == NULL) { + locale = strdup("No locale"); + } + + package.krate = name; + package.id = pkgid; + package.locale = locale; + + free(locale); + + try { + runtime::User user(name); + ::PackageInfo pkginfo(pkgid, user.getUid()); + + package.type = pkginfo.getType(); + package.icon = pkginfo.getIcon(); + package.label = pkginfo.getLabel(); + package.description = pkginfo.getDescription(); + + package.author.name = pkginfo.getAuthorName(); + package.author.email = pkginfo.getAuthorEmail(); + package.author.href = pkginfo.getAuthorHref(); + + package.version = pkginfo.getVersion(); + package.apiVersion = pkginfo.getApiVersion(); + package.mainAppId = pkginfo.getMainAppId(); + + package.isSystem = pkginfo.isSystem(); + package.isRemovable = pkginfo.isRemovable(); + package.isPreload = pkginfo.isPreload(); + } catch (runtime::Exception& e) { + ERROR("Failed to retrieve package info installed in the krate"); + } + + return package; +} + +std::vector PackageProxy::getPackageList(const std::string& name) +{ + try { + runtime::User user(name); + PackageManager& packman = PackageManager::instance(); + return packman.getPackageList(user.getUid()); + } catch (runtime::Exception& e) { + ERROR("Failed to retrieve package info installed in the krate"); + } + return std::vector(); +} + + +int PackageProxy::install(const std::string& name, const std::string& pkgpath) +{ + try { + runtime::User user(name); + PackageManager& packman = PackageManager::instance(); + packman.installPackage(pkgpath, user.getUid()); + } catch (runtime::Exception& e) { + ERROR("Failed to install package in the krate"); + return -1; + } + + return 0; +} + +int PackageProxy::uninstall(const std::string& name, const std::string& pkgid) +{ + try { + runtime::User user(name); + PackageManager& packman = PackageManager::instance(); + packman.uninstallPackage(pkgid, user.getUid()); + } catch (runtime::Exception& e) { + ERROR("Failed to uninstall package of pkgid in the krate"); + return -1; + } + return 0; +} + +} // namespace Krate diff --git a/server/packman.cpp b/server/packman.cpp new file mode 100644 index 0000000..8739dce --- /dev/null +++ b/server/packman.cpp @@ -0,0 +1,427 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "packman.h" + +namespace { + +int PackageEventCallback(uid_t uid, int id, const char* type, const char* name, + const char* key, const char* val, const void* msg, void* data) +{ + return 0; +} + +int AppListCallback(pkgmgrinfo_appinfo_h handle, void *data) +{ + std::vector* appList = static_cast*>(data); + appList->push_back(ApplicationInfo(handle)); + + return 0; +} + +int PackageListCallback(pkgmgrinfo_pkginfo_h handle, void *data) +{ + char* pkgid = nullptr; + ::pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); + + std::vector* packageList = static_cast*>(data); + packageList->push_back(pkgid); + + return 0; +} + +} // namespace + +PackageInfo::PackageInfo(const std::string& pkgid, uid_t uid) : + user(uid), handle(nullptr) +{ + if (uid == 0) { + uid = getuid(); + } + + if (::pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid.c_str(), user, &handle) != PMINFO_R_OK) { + throw runtime::Exception("Invalid Package Id"); + } +} + +PackageInfo::~PackageInfo() +{ + ::pkgmgrinfo_pkginfo_destroy_pkginfo(handle); +} + +std::vector PackageInfo::getAppList() const +{ + std::vector appList; + + if (::pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP, AppListCallback, &appList, user) != PMINFO_R_OK) { + ERROR("Error in pkgmgrinfo_appinfo_get_usr_list"); + } + + return appList; +} + +std::string PackageInfo::getType() const +{ + char *pkgtype; + if (::pkgmgrinfo_pkginfo_get_type(handle, &pkgtype) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return pkgtype; +} + +std::string PackageInfo::getLabel() const +{ + char *label; + if (::pkgmgrinfo_pkginfo_get_label(handle, &label) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return label; +} + +std::string PackageInfo::getIcon() const +{ + char *icon; + if (::pkgmgrinfo_pkginfo_get_icon(handle, &icon) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return icon; +} + +std::string PackageInfo::getDescription() const +{ + char *desc; + if (::pkgmgrinfo_pkginfo_get_description(handle, &desc) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return desc; +} + +std::string PackageInfo::getAuthorName() const +{ + char *name; + if (::pkgmgrinfo_pkginfo_get_author_name(handle, &name) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return name; +} + +std::string PackageInfo::getAuthorEmail() const +{ + char *email; + if (::pkgmgrinfo_pkginfo_get_author_email(handle, &email) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return email; +} + +std::string PackageInfo::getAuthorHref() const +{ + char *href; + if (::pkgmgrinfo_pkginfo_get_author_name(handle, &href) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return href; +} + +std::string PackageInfo::getVersion() const +{ + char *version; + if (::pkgmgrinfo_pkginfo_get_version(handle, &version) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return version; +} + +std::string PackageInfo::getApiVersion() const +{ + char *api; + if (::pkgmgrinfo_pkginfo_get_api_version(handle, &api) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return api; +} + +std::string PackageInfo::getMainAppId() const +{ + char *mainappid; + if (::pkgmgrinfo_pkginfo_get_mainappid(handle, &mainappid) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return mainappid; +} + +bool PackageInfo::isSystem() const +{ + bool ret; + if (::pkgmgrinfo_pkginfo_is_system(handle, &ret) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return ret; +} + +bool PackageInfo::isRemovable() const +{ + bool ret; + if (::pkgmgrinfo_pkginfo_is_removable(handle, &ret) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return ret; +} + +bool PackageInfo::isPreload() const +{ + bool ret; + if (::pkgmgrinfo_pkginfo_is_preload(handle, &ret) != PMINFO_R_OK) { + throw runtime::Exception("Invalid operation"); + } + + return ret; +} + +ApplicationInfo::ApplicationInfo(const std::string& aid, uid_t uid) +{ + pkgmgrinfo_appinfo_h handle; + + if (::pkgmgrinfo_appinfo_get_usr_appinfo(aid.c_str(), uid, &handle) != PMINFO_R_OK) { + throw runtime::Exception("Invalid App Id"); + } + + load(handle); + + ::pkgmgrinfo_appinfo_destroy_appinfo(handle); +} + +ApplicationInfo::ApplicationInfo(pkgmgrinfo_appinfo_h handle) +{ + load(handle); +} + + +ApplicationInfo::~ApplicationInfo() +{ +} + +void ApplicationInfo::load(pkgmgrinfo_appinfo_h handle) { + pkgmgrinfo_app_component comp; + char* str; + int ret; + + ret = ::pkgmgrinfo_appinfo_get_appid(handle, &str); + if (ret == PMINFO_R_OK) { + id = str; + } + + ret = ::pkgmgrinfo_appinfo_get_pkgid(handle, &str); + if (ret == PMINFO_R_OK) { + package = str; + } + + ret = ::pkgmgrinfo_appinfo_get_apptype(handle, &str); + if (ret == PMINFO_R_OK) { + type = str; + } + + ret = ::pkgmgrinfo_appinfo_get_icon(handle, &str); + if (ret == PMINFO_R_OK) { + icon = str; + } + + ret = ::pkgmgrinfo_appinfo_get_label(handle, &str); + if (ret == PMINFO_R_OK) { + label = str; + } + + ret = ::pkgmgrinfo_appinfo_get_component(handle, &comp); + if (ret == PMINFO_R_OK) { + componentType = static_cast(comp); + } + + ::pkgmgrinfo_appinfo_is_nodisplay(handle, &noDisplayed); + ::pkgmgrinfo_appinfo_is_taskmanage(handle, &taskManaged); +} + +const std::string& ApplicationInfo::getId() const +{ + return id; +} + +const std::string& ApplicationInfo::getPackage() const +{ + return package; +} + +const std::string& ApplicationInfo::getType() const +{ + return type; +} + +const std::string& ApplicationInfo::getIcon() const +{ + return icon; +} + +const std::string& ApplicationInfo::getLabel() const +{ + return label; +} + +int ApplicationInfo::getComponentType() const +{ + return componentType; +} + +bool ApplicationInfo::isNoDisplayed() const +{ + return noDisplayed; +} + +bool ApplicationInfo::isTaskManaged() const +{ + return taskManaged; +} + +PackageManager::PackageManager() : + nativeRequestHandle(nullptr), nativeListenHandle(nullptr) +{ + nativeRequestHandle = ::pkgmgr_client_new(PC_REQUEST); + if (nativeRequestHandle == nullptr) { + throw runtime::Exception("No package manager request instance"); + } + + nativeListenHandle = ::pkgmgr_client_new(PC_LISTENING); + if (nativeListenHandle == nullptr) { + ::pkgmgr_client_free(nativeRequestHandle); + throw runtime::Exception("No package manager listening instance"); + } +} + +PackageManager::~PackageManager() +{ + ::pkgmgr_client_free(nativeRequestHandle); + ::pkgmgr_client_free(nativeListenHandle); +} + +PackageManager& PackageManager::instance() +{ + static PackageManager __instance__; + return __instance__; +} + +void PackageManager::setEventCallback(pkgmgrinfo_handler callback, void* user_data) +{ + int ret; + ret = ::pkgmgr_client_listen_status(nativeListenHandle, callback, user_data); + if (ret < 0) { + throw runtime::Exception("Failed to set package event callback"); + } +} + +void PackageManager::unsetEventCallback() +{ + int ret; + ret = ::pkgmgr_client_remove_listen_status(nativeListenHandle); + if (ret < 0) { + throw runtime::Exception("Failed to unset package event callback"); + } +} + +void PackageManager::installPackage(const std::string& pkgpath, const uid_t user) +{ + int ret = ::pkgmgr_client_usr_install(nativeRequestHandle, NULL, NULL, pkgpath.c_str(), NULL, PM_QUIET, PackageEventCallback, nullptr, user); + if (ret < PKGMGR_R_OK) { + throw runtime::Exception("Package installation failed"); + } +} + +void PackageManager::uninstallPackage(const std::string& pkgid, const uid_t user) +{ + std::string pkgtype; + + PackageInfo pkgInfo(pkgid, user); + pkgtype = pkgInfo.getType(); + + int ret = ::pkgmgr_client_usr_uninstall(nativeRequestHandle, pkgtype.c_str(), pkgid.c_str(), PM_QUIET, PackageEventCallback, nullptr, user); + if (ret < PKGMGR_R_OK) { + ERROR("Error in pkgmgr_client_uninstall"); + throw runtime::Exception("Package manager exception"); + } +} + +std::vector PackageManager::getPackageList(const uid_t user) +{ + std::vector packageList; + + if (::pkgmgrinfo_pkginfo_get_usr_list(PackageListCallback, &packageList, user) != PMINFO_R_OK) { + ERROR("Error in pkgmgrinfo_pkginfo_get_list"); + } + + return packageList; +} + +std::vector PackageManager::getAppList(const uid_t user) +{ + std::vector appList; + + if (::pkgmgrinfo_appinfo_get_usr_installed_list(AppListCallback, user, &appList) != PMINFO_R_OK) { + ERROR("Error in pkgmgrinfo_appinfo_get_installed_list"); + } + + return appList; +} + +void PackageManager::setModeRestriction(int mode, uid_t user) +{ + if (::pkgmgr_client_usr_set_restriction_mode(nativeRequestHandle, + mode, + user) != PKGMGR_R_OK) { + throw runtime::Exception("Failed to set package restriction mode"); + } +} + +void PackageManager::unsetModeRestriction(int mode, uid_t user) +{ + if (::pkgmgr_client_usr_unset_restriction_mode(nativeRequestHandle, + mode, + user) != PKGMGR_R_OK) { + throw runtime::Exception("Failed to unset package mode restriction"); + } +} + +int PackageManager::getModeRestriction(uid_t user) +{ + int mode; + if (::pkgmgr_client_usr_get_restriction_mode(nativeRequestHandle, + &mode, + user) != PKGMGR_R_OK) { + throw runtime::Exception("Failed to get package restriction mode"); + } + + return mode; +} diff --git a/server/packman.h b/server/packman.h new file mode 100644 index 0000000..0609538 --- /dev/null +++ b/server/packman.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __PACKMAN_H__ +#define __PACKMAN_H__ + +#include +#include + +#include +#include + +#include +#include + +class ApplicationInfo { +public: + ApplicationInfo(const std::string& aid, uid_t uid = 0); + ApplicationInfo(pkgmgrinfo_appinfo_h handle); + ~ApplicationInfo(); + + const std::string& getId() const; + const std::string& getPackage() const; + const std::string& getType() const; + const std::string& getIcon() const; + const std::string& getLabel() const; + int getComponentType() const; + bool isNoDisplayed() const; + bool isTaskManaged() const; + +private: + void load(pkgmgrinfo_appinfo_h handle); + + std::string id; + std::string package; + std::string type; + std::string icon; + std::string label; + int componentType; + bool noDisplayed; + bool taskManaged; +}; + +class PackageInfo { +public: + PackageInfo(const std::string& pkgid, uid_t uid = 0); + ~PackageInfo(); + + std::vector getAppList() const; + + std::string getType() const; + std::string getIcon() const; + std::string getLabel() const; + std::string getDescription() const; + + std::string getAuthorName() const; + std::string getAuthorEmail() const; + std::string getAuthorHref() const; + + std::string getVersion() const; + std::string getApiVersion() const; + std::string getMainAppId() const; + + bool isSystem() const; + bool isRemovable() const; + bool isPreload() const; + +private: + uid_t user; + pkgmgrinfo_pkginfo_h handle; +}; + +class PackageManager { +public: + void installPackage(const std::string& pkgpath, const uid_t user); + void uninstallPackage(const std::string& pkgid, const uid_t user); + + std::vector getPackageList(const uid_t user); + std::vector getAppList(const uid_t user); + + void setEventCallback(pkgmgrinfo_handler callback, void* user_data); + void unsetEventCallback(); + + void setModeRestriction(int mode, uid_t user); + void unsetModeRestriction(int mode, uid_t user); + int getModeRestriction(uid_t user); + + void setPackageRestriction(const std::string& pkgid, int mode, uid_t user); + void unsetPackageRestriction(const std::string& pkgid, int mode, uid_t user); + int getPackageRestriction(const std::string& pkgid, uid_t user); + + static PackageManager& instance(); + +private: + PackageManager(); + ~PackageManager(); + +private: + pkgmgr_client *nativeRequestHandle, *nativeListenHandle; +}; + +#endif // __PACKMAN_H__ diff --git a/server/server.cpp b/server/server.cpp new file mode 100644 index 0000000..4db963d --- /dev/null +++ b/server/server.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +#include "server.h" + +#include "rmi/manager.h" +#include "rmi/app-proxy.h" +#include "rmi/package-proxy.h" + +using namespace std::placeholders; + +namespace { + +const std::string KRATE_MANAGER_ADDRESS = "/tmp/.krate.sock"; + +std::unique_ptr manager; +std::unique_ptr appProxy; +std::unique_ptr packageProxy; + +} // namespace + +Server::Server() +{ + service.reset(new rmi::Service(KRATE_MANAGER_ADDRESS)); + + service->setPrivilegeChecker(std::bind(&Server::checkPeerPrivilege, this, _1, _2)); + + service->registerParametricMethod(this, "", (runtime::FileDescriptor)(Server::registerNotificationSubscriber)(std::string)); + service->registerParametricMethod(this, "", (int)(Server::unregisterNotificationSubscriber)(std::string, int)); + + manager.reset(new Krate::Manager(*this)); + appProxy.reset(new Krate::AppProxy(*this)); + packageProxy.reset(new Krate::PackageProxy(*this)); +} + +Server::~Server() +{ +} + +void Server::run() +{ + // Prepare execution environment + service->start(true); +} + +void Server::terminate() +{ + service->stop(); +} + +runtime::FileDescriptor Server::registerNotificationSubscriber(const std::string& name) +{ + return runtime::FileDescriptor(service->subscribeNotification(name), true); +} + +int Server::unregisterNotificationSubscriber(const std::string& name, int id) +{ + return service->unsubscribeNotification(name, id); +} + +bool Server::checkPeerPrivilege(const rmi::Credentials& cred, const std::string& privilege) +{ + cynara *p_cynara; + + if (privilege.empty()) { + return true; + } + + if (::cynara_initialize(&p_cynara, NULL) != CYNARA_API_SUCCESS) { + ERROR("Failure in cynara API"); + return false; + } + + if (::cynara_check(p_cynara, cred.security.c_str(), "", + std::to_string(cred.uid).c_str(), + privilege.c_str()) != CYNARA_API_ACCESS_ALLOWED) { + ::cynara_finish(p_cynara); + ERROR("Access denied: " + cred.security + " : " + privilege); + return false; + } + + ::cynara_finish(p_cynara); + + return true; +} diff --git a/server/server.h b/server/server.h new file mode 100644 index 0000000..95bc9fc --- /dev/null +++ b/server/server.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + */ + +#ifndef __KRATE_SERVER_H__ +#define __KRATE_SERVER_H__ + +#include +#include + +#include +#include +#include + +class Server { +public: + Server(); + ~Server(); + + void run(); + void terminate(); + + template + void setMethodHandler(const std::string& privilege, const std::string& method, + const typename rmi::MethodHandler::type& handler) + { + service->setMethodHandler(privilege, method, handler); + } + + template + void notify(const std::string& name, Args&&... args) + { + service->notify(name, std::forward(args)...); + } + + uid_t getPeerUid() const + { + return service->getPeerUid(); + } + + gid_t getPeerGid() const + { + return service->getPeerGid(); + } + + pid_t getPeerPid() const + { + return service->getPeerPid(); + } + + void createNotification(const std::string& name) + { + service->createNotification(name); + } + + runtime::FileDescriptor registerNotificationSubscriber(const std::string& name); + int unregisterNotificationSubscriber(const std::string& name, int id); + + bool checkPeerPrivilege(const rmi::Credentials& cred, const std::string& privilege); + +private: + std::string securityLabel; + std::unique_ptr service; +}; + +#endif //__KRATE_SERVER_H__ diff --git a/server/systemd/krate.service.in b/server/systemd/krate.service.in index 1e9d228..1680489 100644 --- a/server/systemd/krate.service.in +++ b/server/systemd/krate.service.in @@ -1,11 +1,14 @@ [Unit] -Description=Krate +Description=@PROJECT_NAME@ management daemon [Service] Type=simple -ExecStart=${TZ_SYS_BIN}/krate +SmackProcessLabel=System +ExecStart=@BIN_DIR@/@PROJECT_NAME@d Restart=on-failure ExecReload=/bin/kill -HUP $MAINPID +CapabilityBoundingSet=~CAP_MAC_ADMIN +CapabilityBoundingSet=~CAP_MAC_OVERRIDE [Install] WantedBy=multi-user.target diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 2ce3d84..813d2e7 100755 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -15,7 +15,7 @@ # SET(KRATE_APPS ${KRATE_TOOLS}/apps) -#SET(KRATE_CLI ${KRATE_TOOLS}/cli) +SET(KRATE_CLI ${KRATE_TOOLS}/cli) ADD_SUBDIRECTORY(${KRATE_APPS}) -#ADD_SUBDIRECTORY(${KRATE_CLI}) +ADD_SUBDIRECTORY(${KRATE_CLI}) diff --git a/tools/apps/kaskit/src/main.c b/tools/apps/kaskit/src/main.c index 8b1018c..42ca637 100644 --- a/tools/apps/kaskit/src/main.c +++ b/tools/apps/kaskit/src/main.c @@ -150,7 +150,7 @@ static void __badge_changed_cb(unsigned int action, const char *app_id, unsigned } -static char* __get_current_zone_name() { +static char* __get_current_krate_name() { struct passwd pwd, *result; int bufsize; @@ -192,9 +192,9 @@ void _icon_uninstalled_cb(const char *pkg_id) static void __show_launcher() { - char *zone_name = __get_current_zone_name(); + char *krate_name = __get_current_krate_name(); - _set_kaskit_window_title(zone_name); + _set_kaskit_window_title(krate_name); package_manager_set_event_status(__pkg_mgr, PACKAGE_MANAGER_STATUS_TYPE_INSTALL | @@ -205,7 +205,7 @@ static void __show_launcher() ecore_thread_run(__create_icon_thread, NULL, NULL, NULL); - free(zone_name); + free(krate_name); } static bool __app_create(void *data) diff --git a/tools/apps/kaskit/src/widget.c b/tools/apps/kaskit/src/widget.c index b6bf05a..5df7275 100644 --- a/tools/apps/kaskit/src/widget.c +++ b/tools/apps/kaskit/src/widget.c @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard application + * Tizen Krate Setup-Wizard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * diff --git a/tools/apps/keyguard/CMakeLists.txt b/tools/apps/keyguard/CMakeLists.txt index f60c758..b119716 100644 --- a/tools/apps/keyguard/CMakeLists.txt +++ b/tools/apps/keyguard/CMakeLists.txt @@ -7,10 +7,9 @@ FIND_PACKAGE(PkgConfig REQUIRED) PKG_CHECK_MODULES(KEYGUARD REQUIRED auth-fw shortcut - zone ) -INCLUDE_DIRECTORIES(${EFL_APP_INCLUDE_DIRS} ${KEYGUARD_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${EFL_APP_INCLUDE_DIRS} ${KEYGUARD_INCLUDE_DIRS} ${KRATE_LIB}) LINK_DIRECTORIES(${EFL_APP_LIBRARY_DIRS} ${KEYGUARD_LIBRARY_DIRS}) SET(PROJECT_SRC src/main.c @@ -23,7 +22,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") ADD_EXECUTABLE(${PROJECT_NAME} ${PROJECT_SRC}) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${APP_INSTALL_PREFIX}/${PROJECT_NAME}/bin) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${EFL_APP_LIBRARIES} ${KEYGUARD_LIBRARIES}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${EFL_APP_LIBRARIES} ${KEYGUARD_LIBRARIES} krate) ADD_CUSTOM_TARGET(${PROJECT_NAME}.edj COMMAND edje_cc -no-save -id ${CMAKE_CURRENT_SOURCE_DIR}/res/images diff --git a/tools/apps/keyguard/include/keyguard.h b/tools/apps/keyguard/include/keyguard.h index 2ff94be..6ae44a0 100644 --- a/tools/apps/keyguard/include/keyguard.h +++ b/tools/apps/keyguard/include/keyguard.h @@ -1,5 +1,5 @@ /* - * Tizen Zone Keyguard application + * Tizen Krate Keyguard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * @@ -16,8 +16,8 @@ * limitations under the License. * */ -#ifndef __ZONE_KEYGUARD_H__ -#define __ZONE_KEYGUARD_H__ +#ifndef __KRATE_KEYGUARD_H__ +#define __KRATE_KEYGUARD_H__ #include #include @@ -31,8 +31,8 @@ #include #include #include -#include -#include +#include +#include #ifdef LOG_TAG #undef LOG_TAG @@ -53,4 +53,4 @@ bool _has_password(void); bool _check_password(const char* password); unsigned int _get_left_attempts(void); -#endif /* __ZONE_KEYGUARD_H__ */ +#endif /* __KRATE_KEYGUARD_H__ */ diff --git a/tools/apps/keyguard/include/widget.h b/tools/apps/keyguard/include/widget.h index 85496d9..4d6237b 100644 --- a/tools/apps/keyguard/include/widget.h +++ b/tools/apps/keyguard/include/widget.h @@ -1,5 +1,5 @@ /* - * Tizen Zone Keyguard application + * Tizen Krate Keyguard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * diff --git a/tools/apps/keyguard/res/edje/keyguard.edc b/tools/apps/keyguard/res/edje/keyguard.edc index dd82199..4fd6bf4 100644 --- a/tools/apps/keyguard/res/edje/keyguard.edc +++ b/tools/apps/keyguard/res/edje/keyguard.edc @@ -1,5 +1,5 @@ /* - * Tizen Zone Keyguard Layout + * Tizen Krate Keyguard Layout * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * diff --git a/tools/apps/keyguard/src/main.c b/tools/apps/keyguard/src/main.c index 48f4a5b..25b272c 100644 --- a/tools/apps/keyguard/src/main.c +++ b/tools/apps/keyguard/src/main.c @@ -1,5 +1,5 @@ /* - * Tizen Zone Keyguard application + * Tizen Krate Keyguard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * @@ -60,24 +60,24 @@ unsigned int _get_left_attempts() return max_attempt - attempt; } -static void __launch_zone_app(const char* zone_name, app_control_h app_control) +static void __launch_krate_app(const char* krate_name, app_control_h app_control) { - zone_manager_h zone_mgr; - zone_app_proxy_h zone_app; - - zone_manager_create(&zone_mgr); - zone_app_proxy_create(zone_mgr, zone_name, &zone_app); - zone_app_proxy_send_launch_request(zone_app, app_control); - zone_app_proxy_destroy(zone_app); - zone_manager_destroy(zone_mgr); + krate_manager_h krate_mgr; + krate_app_proxy_h krate_app; + + krate_manager_create(&krate_mgr); + krate_app_proxy_create(krate_mgr, krate_name, &krate_app); + krate_app_proxy_send_launch_request(krate_app, app_control); + krate_app_proxy_destroy(krate_app); + krate_manager_destroy(krate_mgr); } -static void __add_shortcut(const char* zone_name) +static void __add_shortcut(const char* krate_name) { char uri[PATH_MAX]; - snprintf(uri, sizeof(uri), "zone://enter/%s", zone_name); - shortcut_add_to_home(zone_name, LAUNCH_BY_URI, uri, "", 0, NULL, NULL); + snprintf(uri, sizeof(uri), "krate://enter/%s", krate_name); + shortcut_add_to_home(krate_name, LAUNCH_BY_URI, uri, "", 0, NULL, NULL); } static bool __app_create(void *data) @@ -112,28 +112,28 @@ static void __app_control(app_control_h app_control, void *data) return; } - if (strncmp(uri, "zone://", sizeof("zone://") - 1) != 0) { + if (strncmp(uri, "krate://", sizeof("krate://") - 1) != 0) { dlog_print(DLOG_ERROR, LOG_TAG, "Mismatched URI"); free(uri); ui_app_exit(); return; } - tmp = uri + sizeof("zone://") - 1; + tmp = uri + sizeof("krate://") - 1; if (strncmp(tmp, "setup/", sizeof("setup/") - 1) == 0) { - char *zone_name; + char *krate_name; - zone_name = tmp + sizeof("setup/") - 1; - __add_shortcut(zone_name); + krate_name = tmp + sizeof("setup/") - 1; + __add_shortcut(krate_name); ui_app_exit(); return; } else if (strncmp(tmp, "enter/", sizeof("enter/") - 1) == 0) { - char* zone_name, *launch_parameter; + char* krate_name, *launch_parameter; char new_uri[PATH_MAX]; - zone_name = tmp + sizeof("enter/") - 1; - launch_parameter = strchr(zone_name, '/'); + krate_name = tmp + sizeof("enter/") - 1; + launch_parameter = strchr(krate_name, '/'); if (launch_parameter != NULL) { *(launch_parameter++) = '\0'; if (launch_parameter[0] == '\0') { @@ -142,16 +142,15 @@ static void __app_control(app_control_h app_control, void *data) } else { launch_parameter = KASKIT_PACKAGE; } - snprintf(new_uri, PATH_MAX, "zone://launch/%s", launch_parameter); + snprintf(new_uri, PATH_MAX, "krate://launch/%s", launch_parameter); app_control_set_uri(app_control, new_uri); app_control_set_app_id(app_control, PACKAGE); - dlog_print(DLOG_ERROR, LOG_TAG, "Wow"); dlog_print(DLOG_ERROR, LOG_TAG, PACKAGE); dlog_print(DLOG_ERROR, LOG_TAG, new_uri); - dlog_print(DLOG_ERROR, LOG_TAG, zone_name); + dlog_print(DLOG_ERROR, LOG_TAG, krate_name); - __launch_zone_app(zone_name, app_control); + __launch_krate_app(krate_name, app_control); ui_app_exit(); return; }else if (strncmp(tmp, "launch/", sizeof("launch/") - 1) == 0) { diff --git a/tools/apps/keyguard/src/ui.c b/tools/apps/keyguard/src/ui.c index 27c812f..45a649c 100644 --- a/tools/apps/keyguard/src/ui.c +++ b/tools/apps/keyguard/src/ui.c @@ -1,5 +1,5 @@ /* - * Tizen Zone Keyguard application + * Tizen Krate Keyguard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * diff --git a/tools/apps/keyguard/src/widget.c b/tools/apps/keyguard/src/widget.c index 8d6c682..c92b902 100644 --- a/tools/apps/keyguard/src/widget.c +++ b/tools/apps/keyguard/src/widget.c @@ -1,5 +1,5 @@ /* - * Tizen Zone Keyguard application + * Tizen Krate Keyguard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * diff --git a/tools/apps/setup-wizard/CMakeLists.txt b/tools/apps/setup-wizard/CMakeLists.txt index eea89ca..e495026 100644 --- a/tools/apps/setup-wizard/CMakeLists.txt +++ b/tools/apps/setup-wizard/CMakeLists.txt @@ -6,10 +6,9 @@ INCLUDE_DIRECTORIES(./include) FIND_PACKAGE(PkgConfig REQUIRED) PKG_CHECK_MODULES(SETUP_WIZARD REQUIRED notification - zone ) -INCLUDE_DIRECTORIES(${EFL_APP_INCLUDE_DIRS} ${SETUP_WIZARD_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${EFL_APP_INCLUDE_DIRS} ${SETUP_WIZARD_INCLUDE_DIRS} ${KRATE_LIB}) LINK_DIRECTORIES(${EFL_APP_LIBRARY_DIRS} ${SETUP_WIZARD_LIBRARY_DIRS}) SET(PACKAGE_SRC src/main.c @@ -24,7 +23,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") ADD_EXECUTABLE(${PROJECT_NAME} ${PACKAGE_SRC}) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${APP_INSTALL_PREFIX}/${PROJECT_NAME}/bin) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${EFL_APP_LIBRARIES} ${SETUP_WIZARD_LIBRARIES}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${EFL_APP_LIBRARIES} ${SETUP_WIZARD_LIBRARIES} krate) ADD_CUSTOM_TARGET(${PROJECT_NAME}.edj COMMAND edje_cc -no-save -id ${CMAKE_CURRENT_SOURCE_DIR}/res/images diff --git a/tools/apps/setup-wizard/include/krate-setup.h b/tools/apps/setup-wizard/include/krate-setup.h index a003d41..2828c3b 100644 --- a/tools/apps/setup-wizard/include/krate-setup.h +++ b/tools/apps/setup-wizard/include/krate-setup.h @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard application + * Tizen Krate Setup-Wizard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * @@ -16,8 +16,8 @@ * limitations under the License. * */ -#ifndef __ZONE_SETUP_H__ -#define __ZONE_SETUP_H__ +#ifndef __KRATE_SETUP_H__ +#define __KRATE_SETUP_H__ #include #include @@ -29,8 +29,8 @@ #include #include #include -#include -#include +#include +#include #include "setup-text.h" @@ -50,11 +50,11 @@ typedef struct { char *mode; - char *zone_name; - char *zone_password; + char *krate_name; + char *krate_password; - zone_manager_h zone_manager; - int zone_event_cb_id; + krate_manager_h krate_manager; + int krate_event_cb_id; bool request_done; app_control_h app_control; @@ -72,9 +72,9 @@ void _create_security_view(appdata_s *data); void _create_setup_view(appdata_s *data); void _create_two_button_layout(Evas_Object *parent, Evas_Object *left_button, Evas_Object *right_button); -int _send_zone_create_request(appdata_s *ad); -int _send_zone_remove_request(appdata_s *ad); +int _send_krate_create_request(appdata_s *ad); +int _send_krate_remove_request(appdata_s *ad); void _create_notification(app_control_h app_control); -void *zone_request_fail(void *ad); +void *krate_request_fail(void *ad); -#endif /* __ZONE_SETUP_H__ */ +#endif /* __KRATE_SETUP_H__ */ diff --git a/tools/apps/setup-wizard/include/setup-text.h b/tools/apps/setup-wizard/include/setup-text.h index 7d96ad8..ca4a792 100644 --- a/tools/apps/setup-wizard/include/setup-text.h +++ b/tools/apps/setup-wizard/include/setup-text.h @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard application + * Tizen Krate Setup-Wizard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * @@ -38,11 +38,11 @@ #define DELETE_ONGOING_TITLE "Deleting a folder..." #define DELETE_ONGOING_CONTENT "The folder will be removed from
your personal home screen." -#define NOTI_CREATE_ZONE "Separated zone creation" -#define NOTI_BODY_CREATE_ZONE "Tap heare to create Separated Zone." +#define NOTI_CREATE_KRATE "Separated krate creation" +#define NOTI_BODY_CREATE_KRATE "Tap heare to create Separated Krate." -#define NOTI_REMOVE_ZONE "Separated Zone deletion" -#define NOTI_BODY_REMOVE_ZONE "Tap here to delete Separated Zone." +#define NOTI_REMOVE_KRATE "Separated Krate deletion" +#define NOTI_BODY_REMOVE_KRATE "Tap here to delete Separated Krate." #define CANCEL_BUTTON "Cancel" #define NEXT_BUTTON "Next" @@ -52,7 +52,7 @@ #define OK_BUTTON "OK" #define SETUP_POPUP_HEADER "Setup Wizard" -#define BODY_ZONE_CREATE_ERROR "Failed to create the Separated Zone." -#define BODY_ZONE_REMOVE_ERROR "Failed to remove the Separated Zone." +#define BODY_KRATE_CREATE_ERROR "Failed to create the Separated Krate." +#define BODY_KRATE_REMOVE_ERROR "Failed to remove the Separated Krate." #endif /*__SETUP_TEXT_H__*/ diff --git a/tools/apps/setup-wizard/include/widget.h b/tools/apps/setup-wizard/include/widget.h index de65535..febca3c 100644 --- a/tools/apps/setup-wizard/include/widget.h +++ b/tools/apps/setup-wizard/include/widget.h @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard application + * Tizen Krate Setup-Wizard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * diff --git a/tools/apps/setup-wizard/res/edje/layout.edc b/tools/apps/setup-wizard/res/edje/layout.edc index ca1448d..8b521cf 100644 --- a/tools/apps/setup-wizard/res/edje/layout.edc +++ b/tools/apps/setup-wizard/res/edje/layout.edc @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard Layout + * Tizen Krate Setup-Wizard Layout * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * diff --git a/tools/apps/setup-wizard/res/edje/setup.edc b/tools/apps/setup-wizard/res/edje/setup.edc index 8c6ecbd..6262019 100644 --- a/tools/apps/setup-wizard/res/edje/setup.edc +++ b/tools/apps/setup-wizard/res/edje/setup.edc @@ -19,7 +19,7 @@ group { name: "setup_layout"; color: 0 0 0 255; rel1 { relative: 0.0 0.0; to: "bg"; offset: 22 150;} rel2 { relative: 1.0 0.0; to: "bg"; offset: -22 300;} - text { font: "Tizen:style=Regular"; size: "48"; align: 0.5 0.5; text: "Separated Zone";} + text { font: "Tizen:style=Regular"; size: "48"; align: 0.5 0.5; text: "Separated Krate";} } } part { name: "icon_base"; diff --git a/tools/apps/setup-wizard/res/edje/welcome.edc b/tools/apps/setup-wizard/res/edje/welcome.edc index 632f95c..382e402 100644 --- a/tools/apps/setup-wizard/res/edje/welcome.edc +++ b/tools/apps/setup-wizard/res/edje/welcome.edc @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard Layout + * Tizen Krate Setup-Wizard Layout * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * @@ -40,7 +40,7 @@ group { name: "welcome_layout"; color3: 85 88 88 255; rel1 { relative: 0.0 0.0; to: "bg"; offset: 22 150;} rel2 { relative: 1.0 0.0; to: "bg"; offset: -22 300;} - text { font: "Tizen:style=Regular"; size: "48"; align: 0.5 0.5; text: "Separated Zone";} + text { font: "Tizen:style=Regular"; size: "48"; align: 0.5 0.5; text: "Separated Krate";} } } part { name: "icon_base"; diff --git a/tools/apps/setup-wizard/src/main.c b/tools/apps/setup-wizard/src/main.c index 658ed80..20c0bb2 100644 --- a/tools/apps/setup-wizard/src/main.c +++ b/tools/apps/setup-wizard/src/main.c @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard application + * Tizen Krate Setup-Wizard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * @@ -19,39 +19,39 @@ #include "krate-setup.h" #include "widget.h" -static void __launch_zone_app(zone_manager_h zone_mgr, const char *zone_name, app_control_h app_control) +static void __launch_krate_app(krate_manager_h krate_mgr, const char *krate_name, app_control_h app_control) { - zone_app_proxy_h zone_app; + krate_app_proxy_h krate_app; - zone_app_proxy_create(zone_mgr, zone_name, &zone_app); - zone_app_proxy_send_launch_request(zone_app, app_control); - zone_app_proxy_destroy(zone_app); + krate_app_proxy_create(krate_mgr, krate_name, &krate_app); + krate_app_proxy_send_launch_request(krate_app, app_control); + krate_app_proxy_destroy(krate_app); } -static void __zone_request_done(const char *from, const char *info, void *user_data) +static void __krate_request_done(const char *from, const char *info, void *user_data) { app_control_h app_control; char uri[PATH_MAX]; appdata_s *ad = (appdata_s *) user_data; if (!strcmp(info, "Error")) { - ecore_main_loop_thread_safe_call_sync(zone_request_fail, ad); + ecore_main_loop_thread_safe_call_sync(krate_request_fail, ad); return; } if (!strcmp(ad->mode, "create")) { - zone_manager_reset_zone_password(ad->zone_manager, ad->zone_name, ad->zone_password); + krate_manager_reset_krate_password(ad->krate_manager, ad->krate_name, ad->krate_password); app_control_create(&app_control); app_control_set_app_id(app_control, KEYGUARD_PACKAGE); - snprintf(uri, sizeof(uri), "zone://setup/%s", ad->zone_name); + snprintf(uri, sizeof(uri), "krate://setup/%s", ad->krate_name); app_control_set_uri(app_control, uri); app_control_send_launch_request(app_control, NULL, NULL); app_control_destroy(app_control); app_control_create(&app_control); app_control_set_app_id(app_control, KASKIT_PACKAGE); - __launch_zone_app(ad->zone_manager, ad->zone_name, app_control); + __launch_krate_app(ad->krate_manager, ad->krate_name, app_control); app_control_destroy(app_control); } @@ -62,8 +62,8 @@ static bool __app_create(void *data) { appdata_s *ad = (appdata_s *) data; - if (zone_manager_create(&ad->zone_manager) != ZONE_ERROR_NONE) { - dlog_print(DLOG_ERROR, LOG_TAG, "failed to get zone manager handle"); + if (krate_manager_create(&ad->krate_manager) != KRATE_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to get krate manager handle"); ui_app_exit(); return false; } @@ -81,7 +81,7 @@ static void __app_resume(void *data) static void __free_data(appdata_s *ad) { - free(ad->zone_name); + free(ad->krate_name); free(ad->mode); } @@ -89,15 +89,15 @@ static void __app_terminate(void *data) { appdata_s *ad = (appdata_s *) data; - zone_manager_remove_event_cb(ad->zone_manager, ad->zone_event_cb_id); - zone_manager_destroy(ad->zone_manager); + krate_manager_remove_event_cb(ad->krate_manager, ad->krate_event_cb_id); + krate_manager_destroy(ad->krate_manager); __free_data(ad); return ; } -static void __set_zone_callback(appdata_s *ad) +static void __set_krate_callback(appdata_s *ad) { char *cb_event_list[2] = {"created", "removed"}; char *cb_event = NULL; @@ -107,8 +107,8 @@ static void __set_zone_callback(appdata_s *ad) else cb_event = cb_event_list[1]; - if (zone_manager_add_event_cb(ad->zone_manager, cb_event, __zone_request_done, ad, &ad->zone_event_cb_id) != ZONE_ERROR_NONE) { - dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add zone signal callback"); + if (krate_manager_add_event_cb(ad->krate_manager, cb_event, __krate_request_done, ad, &ad->krate_event_cb_id) != KRATE_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add krate signal callback"); ui_app_exit(); } @@ -133,14 +133,14 @@ static void __app_control(app_control_h app_control, void *data) return; } - ret = app_control_get_extra_data(app_control, "zone", &ad->zone_name); + ret = app_control_get_extra_data(app_control, "krate", &ad->krate_name); if (ret != APP_CONTROL_ERROR_NONE) { - dlog_print(DLOG_ERROR, LOG_TAG, "failed to get zone name"); + dlog_print(DLOG_ERROR, LOG_TAG, "failed to get krate name"); ui_app_exit(); return; } - __set_zone_callback(ad); + __set_krate_callback(ad); if (app_control_clone(&ad->app_control, app_control) != APP_CONTROL_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "Failed to clone app control handler"); diff --git a/tools/apps/setup-wizard/src/security.c b/tools/apps/setup-wizard/src/security.c index 80fe455..c80dc54 100644 --- a/tools/apps/setup-wizard/src/security.c +++ b/tools/apps/setup-wizard/src/security.c @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard application + * Tizen Krate Setup-Wizard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * @@ -189,9 +189,9 @@ static void security_password_setup_cb(void *data, Evas_Object *obj, void *event } delete_object_data(); - ad->zone_password = security_password_setup_data; + ad->krate_password = security_password_setup_data; - if (_send_zone_create_request(ad) != 0) { + if (_send_krate_create_request(ad) != 0) { ui_app_exit(); } diff --git a/tools/apps/setup-wizard/src/ui.c b/tools/apps/setup-wizard/src/ui.c index c8a4937..30be539 100644 --- a/tools/apps/setup-wizard/src/ui.c +++ b/tools/apps/setup-wizard/src/ui.c @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard application + * Tizen Krate Setup-Wizard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * @@ -50,8 +50,8 @@ static void setup_wizard_next_cb(void *data, Evas_Object *obj, void *event_info) if (!strcmp(ad->mode, "create")) { _create_security_view(ad); } else { - if (_send_zone_remove_request(ad) != 0) { - ecore_main_loop_thread_safe_call_sync(zone_request_fail, ad); + if (_send_krate_remove_request(ad) != 0) { + ecore_main_loop_thread_safe_call_sync(krate_request_fail, ad); return; } _create_setup_view(ad); @@ -96,15 +96,15 @@ static Eina_Bool __progressbar_timer_cb(void *data) return ECORE_CALLBACK_RENEW; } -void *zone_request_fail(void *user_data) +void *krate_request_fail(void *user_data) { Evas_Object *popup = NULL; appdata_s *ad = (appdata_s *)user_data; if (!strcmp(ad->mode, "create")) - popup = _create_popup(ud.win, SETUP_POPUP_HEADER, BODY_ZONE_CREATE_ERROR); + popup = _create_popup(ud.win, SETUP_POPUP_HEADER, BODY_KRATE_CREATE_ERROR); else - popup = _create_popup(ud.win, SETUP_POPUP_HEADER, BODY_ZONE_REMOVE_ERROR); + popup = _create_popup(ud.win, SETUP_POPUP_HEADER, BODY_KRATE_REMOVE_ERROR); Evas_Object *btn = elm_button_add(popup); elm_object_style_set(btn, "popup"); diff --git a/tools/apps/setup-wizard/src/util.c b/tools/apps/setup-wizard/src/util.c index 7ad63ee..8112db2 100644 --- a/tools/apps/setup-wizard/src/util.c +++ b/tools/apps/setup-wizard/src/util.c @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard application + * Tizen Krate Setup-Wizard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * @@ -19,9 +19,9 @@ #include #include "krate-setup.h" -#define ZONE_METADATA_PATH "data/KrateManifest.xml" +#define KRATE_METADATA_PATH "data/KrateManifest.xml" -static char *__get_zone_metadata(void) +static char *__get_krate_metadata(void) { FILE *fp = NULL; char *res_path = NULL; @@ -35,7 +35,7 @@ static char *__get_zone_metadata(void) dlog_print(DLOG_ERROR, LOG_TAG, "failed to get resource path"); return NULL; } - snprintf(metadata_path, PATH_MAX, "%s%s", res_path, ZONE_METADATA_PATH); + snprintf(metadata_path, PATH_MAX, "%s%s", res_path, KRATE_METADATA_PATH); free(res_path); fp = fopen(metadata_path, "r"); @@ -81,31 +81,31 @@ static char *__get_zone_metadata(void) return metadata; } -int _send_zone_create_request(appdata_s *ad) +int _send_krate_create_request(appdata_s *ad) { int ret; char *metadata = NULL; - metadata = __get_zone_metadata(); + metadata = __get_krate_metadata(); if (metadata == NULL) { - dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get zone metadata"); + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get krate metadata"); return -1; } - ret = zone_manager_create_zone(ad->zone_manager, ad->zone_name, metadata); - if (ret != ZONE_ERROR_NONE) { + ret = krate_manager_create_krate(ad->krate_manager, ad->krate_name, metadata); + if (ret != KRATE_ERROR_NONE) { return -1; } return 0; } -int _send_zone_remove_request(appdata_s *ad) +int _send_krate_remove_request(appdata_s *ad) { int ret; - ret = zone_manager_destroy_zone(ad->zone_manager, ad->zone_name); - if (ret != ZONE_ERROR_NONE) { + ret = krate_manager_destroy_krate(ad->krate_manager, ad->krate_name); + if (ret != KRATE_ERROR_NONE) { return -1; } @@ -117,8 +117,8 @@ static int __set_notification(notification_h noti_handle, app_control_h app_cont int ret = 0; char *mode = NULL; char *noti_text[2][2] = { - {NOTI_CREATE_ZONE, NOTI_BODY_CREATE_ZONE}, - {NOTI_REMOVE_ZONE, NOTI_BODY_REMOVE_ZONE} + {NOTI_CREATE_KRATE, NOTI_BODY_CREATE_KRATE}, + {NOTI_REMOVE_KRATE, NOTI_BODY_REMOVE_KRATE} }; char **text = NULL; diff --git a/tools/apps/setup-wizard/src/widget.c b/tools/apps/setup-wizard/src/widget.c index 426a404..6a94dc4 100644 --- a/tools/apps/setup-wizard/src/widget.c +++ b/tools/apps/setup-wizard/src/widget.c @@ -1,5 +1,5 @@ /* - * Tizen Zone Setup-Wizard application + * Tizen Krate Setup-Wizard application * * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * diff --git a/tools/cli/CMakeLists.txt b/tools/cli/CMakeLists.txt index 67a843a..75023dd 100644 --- a/tools/cli/CMakeLists.txt +++ b/tools/cli/CMakeLists.txt @@ -19,7 +19,7 @@ FILE(GLOB CLI_SRCS krate-admin-cli.cpp ${KRATE_MODULE}/krate-builder.cpp ) -SET(CLI_NAME "zone-admin-cli") +SET(CLI_NAME ${PROJECT_NAME}-admin-cli) ADD_EXECUTABLE(${CLI_NAME} ${CLI_SRCS}) SET_TARGET_PROPERTIES(${CLI_NAME} PROPERTIES PREFIX "" @@ -34,10 +34,9 @@ PKG_CHECK_MODULES(CLI_DEPS REQUIRED libxml-2.0 capi-appfw-package-manager capi-appfw-app-manager - zone ) -INCLUDE_DIRECTORIES(SYSTEM ${CLI_DEPS_INCLUDE_DIRS} ${KRATE_MODULE}) -TARGET_LINK_LIBRARIES(${CLI_NAME} ${CLI_DEPS_LIBRARIES}) +INCLUDE_DIRECTORIES(SYSTEM ${CLI_DEPS_INCLUDE_DIRS} ${KRATE_MODULE} ${KRATE_LIB}) +TARGET_LINK_LIBRARIES(${CLI_NAME} ${CLI_DEPS_LIBRARIES} krate) INSTALL(TARGETS ${CLI_NAME} DESTINATION sbin) diff --git a/tools/cli/krate-admin-cli.cpp b/tools/cli/krate-admin-cli.cpp index e46e45b..45b7ea2 100644 --- a/tools/cli/krate-admin-cli.cpp +++ b/tools/cli/krate-admin-cli.cpp @@ -44,8 +44,8 @@ #include #include -#include -#include +#include +#include #include "session.h" @@ -237,15 +237,15 @@ int showPkgInfo(const std::string& name) { int num = 0; - zone_manager_h krateMgr; - zone_package_proxy_h pkgProxy; + krate_manager_h krateMgr; + krate_package_proxy_h pkgProxy; - zone_manager_create(&krateMgr); - zone_package_proxy_create(krateMgr, name.c_str(), &pkgProxy); - zone_package_proxy_foreach_package_info(pkgProxy, packgeListCallback, &num); + krate_manager_create(&krateMgr); + krate_package_proxy_create(krateMgr, name.c_str(), &pkgProxy); + krate_package_proxy_foreach_package_info(pkgProxy, packgeListCallback, &num); std::cout << num << " packages are found" << std::endl; - zone_package_proxy_destroy(pkgProxy); - zone_manager_destroy(krateMgr); + krate_package_proxy_destroy(pkgProxy); + krate_manager_destroy(krateMgr); return 0; } @@ -295,15 +295,15 @@ int showAppInfo(const std::string& name) { int num = 0; - zone_manager_h krateMgr; - zone_app_proxy_h appMgr; + krate_manager_h krateMgr; + krate_app_proxy_h appMgr; - zone_manager_create(&krateMgr); - zone_app_proxy_create(krateMgr, name.c_str(), &appMgr); - zone_app_proxy_foreach_app_info(appMgr, applicationListCallback, &num); + krate_manager_create(&krateMgr); + krate_app_proxy_create(krateMgr, name.c_str(), &appMgr); + krate_app_proxy_foreach_app_info(appMgr, applicationListCallback, &num); std::cout << num << " applications are found" << std::endl; - zone_app_proxy_destroy(appMgr); - zone_manager_destroy(krateMgr); + krate_app_proxy_destroy(appMgr); + krate_manager_destroy(krateMgr); return 0; } @@ -326,12 +326,12 @@ void krateCallback(const char* name, const char* object, void *user_data) int monitorEvent() { int krateCallbackId[2]; - zone_manager_h krateMgr; - zone_manager_create(&krateMgr); + krate_manager_h krateMgr; + krate_manager_create(&krateMgr); - zone_manager_add_event_cb(krateMgr, "created", krateCallback, + krate_manager_add_event_cb(krateMgr, "created", krateCallback, (void*)"created", &krateCallbackId[0]); - zone_manager_add_event_cb(krateMgr, "removed", krateCallback, + krate_manager_add_event_cb(krateMgr, "removed", krateCallback, (void*)"removed", &krateCallbackId[1]); std::cout << "=== Monitoring start ===" << std::endl << std::endl; @@ -342,12 +342,12 @@ int monitorEvent() g_main_loop_run(gmainloop); g_main_loop_unref(gmainloop); - zone_manager_remove_event_cb(krateMgr, krateCallbackId[0]); - zone_manager_remove_event_cb(krateMgr, krateCallbackId[1]); + krate_manager_remove_event_cb(krateMgr, krateCallbackId[0]); + krate_manager_remove_event_cb(krateMgr, krateCallbackId[1]); std::cout << "=== Monitoring end ===" << std::endl; - zone_manager_destroy(krateMgr); + krate_manager_destroy(krateMgr); return 0; } @@ -398,13 +398,13 @@ void packageEventCallback(const char *type, int monitorPkgEvent(const std::string& name) { - zone_manager_h krateMgr; - zone_package_proxy_h pkgProxy; + krate_manager_h krateMgr; + krate_package_proxy_h pkgProxy; - zone_manager_create(&krateMgr); - zone_package_proxy_create(krateMgr, name.c_str(), &pkgProxy); + krate_manager_create(&krateMgr); + krate_package_proxy_create(krateMgr, name.c_str(), &pkgProxy); - zone_package_proxy_set_event_cb(pkgProxy, packageEventCallback, NULL); + krate_package_proxy_set_event_cb(pkgProxy, packageEventCallback, NULL); std::cout << "=== Monitoring start ===" << std::endl << std::endl; @@ -414,12 +414,12 @@ int monitorPkgEvent(const std::string& name) g_main_loop_run(gmainloop); g_main_loop_unref(gmainloop); - zone_package_proxy_unset_event_cb(pkgProxy); + krate_package_proxy_unset_event_cb(pkgProxy); std::cout << "=== Monitoring end ===" << std::endl; - zone_package_proxy_destroy(pkgProxy); - zone_manager_destroy(krateMgr); + krate_package_proxy_destroy(pkgProxy); + krate_manager_destroy(krateMgr); return 0; } diff --git a/tools/gumd-scripts/20_krate-add.post b/tools/gumd-scripts/20_krate-add.post index 1d30527..fcaf715 100644 --- a/tools/gumd-scripts/20_krate-add.post +++ b/tools/gumd-scripts/20_krate-add.post @@ -1,4 +1,4 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin export `tzplatform-get TZ_SYS_ETC` -cp ${TZ_SYS_ETC}/dpm/zone/owner.xml ${TZ_SYS_ETC}/dpm/zone/${1}.xml +cp ${TZ_SYS_ETC}/krate/owner.xml ${TZ_SYS_ETC}/krate/${1}.xml diff --git a/tools/gumd-scripts/20_krate-remove.post b/tools/gumd-scripts/20_krate-remove.post index 48bfabe..73112eb 100644 --- a/tools/gumd-scripts/20_krate-remove.post +++ b/tools/gumd-scripts/20_krate-remove.post @@ -1,4 +1,4 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin export `tzplatform-get TZ_SYS_ETC` -rm ${TZ_SYS_ETC}/dpm/zone/${1}.xml +rm ${TZ_SYS_ETC}/krate/${1}.xml -- 2.7.4 From 9532c768fd35ee584ee13cb72f263167900219b4 Mon Sep 17 00:00:00 2001 From: Sungbae Yoo Date: Tue, 9 Aug 2016 16:23:57 +0900 Subject: [PATCH 02/16] Remove build feature Change-Id: I1278e6ead5463b4af7e4735407c2d19f6aa0248b Signed-off-by: Sungbae Yoo --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fb2706..c7e3422 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,4 @@ ADD_SUBDIRECTORY(${KRATE_LIB}) ADD_SUBDIRECTORY(${KRATE_SERVER}) ADD_SUBDIRECTORY(${KRATE_MODULE}) ADD_SUBDIRECTORY(${KRATE_VOLUME}) -IF("${TIZEN_PROFILE_NAME}" STREQUAL "mobile") ADD_SUBDIRECTORY(${KRATE_TOOLS}) -ENDIF() -- 2.7.4 From 963bafdae7597f7ecc9703a38323aa4f2d851c31 Mon Sep 17 00:00:00 2001 From: Sungbae Yoo Date: Wed, 10 Aug 2016 21:32:10 +0900 Subject: [PATCH 03/16] Package-proxy : description value can be NULL Signed-off-by: Sungbae Yoo Change-Id: I5ede0b20251d614ebf17f36abb1ad43c99e5f951 --- server/packman.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/packman.cpp b/server/packman.cpp index 8739dce..1a80e12 100644 --- a/server/packman.cpp +++ b/server/packman.cpp @@ -112,6 +112,9 @@ std::string PackageInfo::getDescription() const throw runtime::Exception("Invalid operation"); } + if (desc == NULL) + return ""; + return desc; } -- 2.7.4 From ecdd2a249e448b382892a8830c3d4de65ebc2a5f Mon Sep 17 00:00:00 2001 From: Sungbae Yoo Date: Wed, 17 Aug 2016 14:35:07 +0900 Subject: [PATCH 04/16] Add final classifier to classes not to be inherited Signed-off-by: Sungbae Yoo Change-Id: Ibc5e4131ac2e5307d91e915d9f019e944938a7fe --- lib/client.h | 2 +- module/krate-builder.h | 2 +- module/krate-guard.h | 2 +- rmi/app-proxy.h | 2 +- rmi/manager.h | 2 +- rmi/package-proxy.h | 2 +- server/app-bundle.h | 2 +- server/launchpad.h | 2 +- server/packman.h | 6 +++--- server/server.h | 2 +- volume/kernel-keyring.h | 2 +- volume/key-generator.h | 2 +- volume/key-manager.h | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/client.h b/lib/client.h index f8d1678..c64d34f 100644 --- a/lib/client.h +++ b/lib/client.h @@ -26,7 +26,7 @@ typedef std::function KrateChangeListener; typedef std::function SignalListener; -class KrateContext { +class KrateContext final { public: typedef std::unique_ptr KrateControlContext; diff --git a/module/krate-builder.h b/module/krate-builder.h index 094b747..1e03ef8 100644 --- a/module/krate-builder.h +++ b/module/krate-builder.h @@ -24,7 +24,7 @@ #include #include -class KrateBuilder { +class KrateBuilder final { public: KrateBuilder(const runtime::User& user, const std::string& manifestPath); virtual ~KrateBuilder(); diff --git a/module/krate-guard.h b/module/krate-guard.h index 8e09748..a19781a 100644 --- a/module/krate-guard.h +++ b/module/krate-guard.h @@ -27,7 +27,7 @@ #include -class KrateGuard { +class KrateGuard final { public: KrateGuard(const std::string& name) : krateName(name), semaphore(nullptr) diff --git a/rmi/app-proxy.h b/rmi/app-proxy.h index 927a8dc..61c0f64 100644 --- a/rmi/app-proxy.h +++ b/rmi/app-proxy.h @@ -25,7 +25,7 @@ namespace Krate { * This class provides APIs to create/remove and manage names. */ -class AppProxy { +class AppProxy final { public: AppProxy(KrateControlContext& ctxt); ~AppProxy(); diff --git a/rmi/manager.h b/rmi/manager.h index 53005f7..97701ca 100644 --- a/rmi/manager.h +++ b/rmi/manager.h @@ -21,7 +21,7 @@ namespace Krate { -class Manager { +class Manager final { public: enum State { Locked = 0x01, diff --git a/rmi/package-proxy.h b/rmi/package-proxy.h index 300d609..271d838 100644 --- a/rmi/package-proxy.h +++ b/rmi/package-proxy.h @@ -25,7 +25,7 @@ namespace Krate { * This class provides APIs to control packages in the krates. */ -class PackageProxy { +class PackageProxy final { public: PackageProxy(KrateControlContext& ctxt); ~PackageProxy(); diff --git a/server/app-bundle.h b/server/app-bundle.h index 9ce75ee..ca53719 100644 --- a/server/app-bundle.h +++ b/server/app-bundle.h @@ -22,7 +22,7 @@ #include -class Bundle { +class Bundle final { public: Bundle(); ~Bundle(); diff --git a/server/launchpad.h b/server/launchpad.h index c3120ed..07f179e 100644 --- a/server/launchpad.h +++ b/server/launchpad.h @@ -21,7 +21,7 @@ #include "app-bundle.h" -class Launchpad { +class Launchpad final { public: Launchpad(const uid_t uid = 0); Launchpad(const Launchpad&) = delete; diff --git a/server/packman.h b/server/packman.h index 0609538..ab54341 100644 --- a/server/packman.h +++ b/server/packman.h @@ -26,7 +26,7 @@ #include #include -class ApplicationInfo { +class ApplicationInfo final { public: ApplicationInfo(const std::string& aid, uid_t uid = 0); ApplicationInfo(pkgmgrinfo_appinfo_h handle); @@ -54,7 +54,7 @@ private: bool taskManaged; }; -class PackageInfo { +class PackageInfo final { public: PackageInfo(const std::string& pkgid, uid_t uid = 0); ~PackageInfo(); @@ -83,7 +83,7 @@ private: pkgmgrinfo_pkginfo_h handle; }; -class PackageManager { +class PackageManager final { public: void installPackage(const std::string& pkgpath, const uid_t user); void uninstallPackage(const std::string& pkgid, const uid_t user); diff --git a/server/server.h b/server/server.h index 95bc9fc..6d07bbe 100644 --- a/server/server.h +++ b/server/server.h @@ -24,7 +24,7 @@ #include #include -class Server { +class Server final { public: Server(); ~Server(); diff --git a/volume/kernel-keyring.h b/volume/kernel-keyring.h index c23d70f..b32668d 100755 --- a/volume/kernel-keyring.h +++ b/volume/kernel-keyring.h @@ -24,7 +24,7 @@ typedef int32_t KeySerial; -class KernelKeyRing { +class KernelKeyRing final { public: KernelKeyRing() = delete; KernelKeyRing(const KernelKeyRing&) = delete; diff --git a/volume/key-generator.h b/volume/key-generator.h index e0d9796..d6bf6f8 100755 --- a/volume/key-generator.h +++ b/volume/key-generator.h @@ -27,7 +27,7 @@ typedef struct { unsigned char buffer[64]; } SHA1_CTX; -class KeyGenerator { +class KeyGenerator final { public: KeyGenerator() = delete; KeyGenerator(const KeyGenerator&) = delete; diff --git a/volume/key-manager.h b/volume/key-manager.h index 48bcdc8..7ca79eb 100644 --- a/volume/key-manager.h +++ b/volume/key-manager.h @@ -17,7 +17,7 @@ #ifndef __KEY_MANAGER_H__ #define __KEY_MANAGER_H__ -class KeyManager { +class KeyManager final { public: KeyManager() = delete; KeyManager(const KeyManager&) = delete; -- 2.7.4 From e914edce4c6067470fc19d828c10930fbef61c6c Mon Sep 17 00:00:00 2001 From: Sungbae Yoo Date: Wed, 17 Aug 2016 21:21:37 +0900 Subject: [PATCH 05/16] Add error handlings when *alloc returns NULL Signed-off-by: Sungbae Yoo Change-Id: I1a820dc052f447fe5ad41dd81230f6cdd9801e49 --- lib/krate/app-proxy.cpp | 39 +++++++++++++++++++++++----------- lib/krate/package-proxy.cpp | 50 +++++++++++++++++++++++++++++++------------- tools/apps/kaskit/src/main.c | 4 ++++ volume/main.cpp | 16 +++++++++----- 4 files changed, 78 insertions(+), 31 deletions(-) diff --git a/lib/krate/app-proxy.cpp b/lib/krate/app-proxy.cpp index 449520d..137cc50 100644 --- a/lib/krate/app-proxy.cpp +++ b/lib/krate/app-proxy.cpp @@ -43,35 +43,50 @@ static app_info_h make_app_info_handle(const Krate::AppProxy::AppInfo& info) return NULL; } - application_x* app = (application_x*)::malloc(sizeof(application_x)); - pkgmgr_appinfo_x* pkgappinfo = (pkgmgr_appinfo_x*)::malloc(sizeof(pkgmgr_appinfo_x)); - app_info_s* appinfo = (app_info_s*)::malloc(sizeof(struct app_info_s)); + application_x* app = (application_x*)::calloc(1, sizeof(application_x)); + if (app == NULL) { + return NULL; + } + + pkgmgr_appinfo_x* pkgappinfo = (pkgmgr_appinfo_x*)::calloc(1, sizeof(pkgmgr_appinfo_x)); + if (pkgappinfo == NULL) { + free(app); + return NULL; + } + + app_info_s* appinfo = (app_info_s*)::calloc(1, sizeof(struct app_info_s)); + if (appinfo == NULL) { + free(app); + free(pkgappinfo); + return NULL; + } - ::memset(appinfo, 0, sizeof(app_info_s)); appinfo->app_id = ::strdup(info.id.c_str()); appinfo->pkg_app_info = pkgappinfo; - ::memset(pkgappinfo, 0, sizeof(pkgmgr_appinfo_x)); pkgappinfo->package = ::strdup(info.package.c_str()); pkgappinfo->locale = ::strdup(info.locale.c_str()); pkgappinfo->app_component = info.componentType; pkgappinfo->app_info = app; - ::memset(app, 0, sizeof(application_x)); app->appid = ::strdup(info.id.c_str()); app->nodisplay = ::strdup(info.isNoDisplayed? "true":"false"); app->taskmanage = ::strdup(info.isTaskManaged? "true":"false"); app->type = ::strdup(info.type.c_str()); icon_x* icon = (icon_x*)::calloc(1, sizeof(icon_x)); - icon->text = ::strdup(info.icon.c_str()); - icon->lang = ::strdup(info.locale.c_str()); - app->icon = ::g_list_append(NULL, icon); + if (icon != NULL) { + icon->text = ::strdup(info.icon.c_str()); + icon->lang = ::strdup(info.locale.c_str()); + app->icon = ::g_list_append(NULL, icon); + } label_x* label = (label_x*)::calloc(1, sizeof(label_x)); - label->text = ::strdup(info.label.c_str()); - label->lang = ::strdup(info.locale.c_str()); - app->label = ::g_list_append(NULL, label); + if (label != NULL) { + label->text = ::strdup(info.label.c_str()); + label->lang = ::strdup(info.locale.c_str()); + app->label = ::g_list_append(NULL, label); + } return reinterpret_cast(appinfo); } diff --git a/lib/krate/package-proxy.cpp b/lib/krate/package-proxy.cpp index 690397e..a78db06 100644 --- a/lib/krate/package-proxy.cpp +++ b/lib/krate/package-proxy.cpp @@ -125,8 +125,22 @@ static package_info_h make_package_info_handle(const PackageProxy::PackageInfo& } package_x* package = (package_x*)::calloc(1, sizeof(package_x)); + if (package == NULL) { + return NULL; + } + pkgmgr_pkginfo_x* pkginfo = (pkgmgr_pkginfo_x*)::calloc(1, sizeof(pkgmgr_pkginfo_x)); + if (pkginfo == NULL) { + free(package); + return NULL; + } + package_info_s* packageinfo = (package_info_s*)::calloc(1, sizeof(package_info_s)); + if (packageinfo == NULL) { + free(package); + free(pkginfo); + return NULL; + } packageinfo->package = ::strdup(info.id.c_str()); packageinfo->pkgmgr_pkginfo = pkginfo; @@ -146,26 +160,34 @@ static package_info_h make_package_info_handle(const PackageProxy::PackageInfo& package->api_version = ::strdup(info.apiVersion.c_str()); icon_x* icon = (icon_x*)::calloc(1, sizeof(icon_x)); - icon->text = ::strdup(info.icon.c_str()); - icon->lang = ::strdup(info.locale.c_str()); - package->icon = ::g_list_append(NULL, icon); + if (icon != NULL) { + icon->text = ::strdup(info.icon.c_str()); + icon->lang = ::strdup(info.locale.c_str()); + package->icon = ::g_list_append(NULL, icon); + } label_x* label = (label_x*)::calloc(1, sizeof(label_x)); - label->text = ::strdup(info.label.c_str()); - label->lang = ::strdup(info.locale.c_str()); - package->label = ::g_list_append(NULL, label); + if (label != NULL) { + label->text = ::strdup(info.label.c_str()); + label->lang = ::strdup(info.locale.c_str()); + package->label = ::g_list_append(NULL, label); + } description_x* desc = (description_x*)::calloc(1, sizeof(description_x)); - desc->text = ::strdup(info.description.c_str()); - desc->lang = ::strdup(info.locale.c_str()); - package->description = ::g_list_append(NULL, desc); + if (desc != NULL) { + desc->text = ::strdup(info.description.c_str()); + desc->lang = ::strdup(info.locale.c_str()); + package->description = ::g_list_append(NULL, desc); + } author_x* author = (author_x*)::calloc(1, sizeof(author_x)); - author->text = ::strdup(info.author.name.c_str()); - author->email = ::strdup(info.author.email.c_str()); - author->href = ::strdup(info.author.href.c_str()); - author->lang = ::strdup(info.locale.c_str()); - package->author = ::g_list_append(NULL, author); + if (author != NULL) { + author->text = ::strdup(info.author.name.c_str()); + author->email = ::strdup(info.author.email.c_str()); + author->href = ::strdup(info.author.href.c_str()); + author->lang = ::strdup(info.locale.c_str()); + package->author = ::g_list_append(NULL, author); + } return reinterpret_cast(packageinfo); } diff --git a/tools/apps/kaskit/src/main.c b/tools/apps/kaskit/src/main.c index 42ca637..172fb7a 100644 --- a/tools/apps/kaskit/src/main.c +++ b/tools/apps/kaskit/src/main.c @@ -161,6 +161,10 @@ static char* __get_current_krate_name() { char* ret, *buf = malloc(bufsize * sizeof(char)); + if (buf == NULL) { + return NULL; + } + getpwuid_r(getuid(), &pwd, buf, bufsize, &result); if (result == NULL) { ret = NULL; diff --git a/volume/main.cpp b/volume/main.cpp index 4de5260..d277009 100755 --- a/volume/main.cpp +++ b/volume/main.cpp @@ -62,7 +62,7 @@ ecryptfs_payload* generateToken(char* key) unsigned char keyBuffer[ECRYPTFS_MAX_KEY_SIZE+1]; - ecryptfs_payload* authToken = (ecryptfs_payload *)::malloc(sizeof(ecryptfs_payload)); + ecryptfs_payload* authToken = new ecryptfs_payload(); if (authToken == NULL) { return NULL; } @@ -112,16 +112,20 @@ int mountEcryptfs(const std::string& src, const std::string& keyName) "user", signature, 0); - if (rc == -1 && errno != ENOKEY) { - ERROR("Failed to find key"); - return -1; - } + if (rc == -1) { + if (errno != ENOKEY) { + ERROR("Failed to find key"); + delete authTok; + return -1; + } + rc = KernelKeyRing::add("user", signature, (void*)authTok, sizeof(ecryptfs_payload), KEY_SPEC_USER_KEYRING); + if (rc == -1) { ERROR("Failed to add key"); return -1; @@ -136,6 +140,8 @@ int mountEcryptfs(const std::string& src, const std::string& keyName) "smackfsroot=*,smackfsdef=*", ECRYPTFS_MAX_KEY_SIZE, signature); + delete authTok; + rc = ::mount(src.c_str(), src.c_str(), "ecryptfs", MS_NODEV, ecryptfsOpts); if (rc != 0) { ERROR(runtime::GetSystemErrorMessage()); -- 2.7.4 From cc65641be1a3e0a8538e6c414518a8ac360f56d9 Mon Sep 17 00:00:00 2001 From: Sungbae Yoo Date: Thu, 18 Aug 2016 18:33:00 +0900 Subject: [PATCH 06/16] Fix an use of key-manager deprecated API Signed-off-by: Sungbae Yoo Change-Id: I0904f03232117b9fd9bebe3134752328f0e7fc77 --- volume/key-manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/volume/key-manager.cpp b/volume/key-manager.cpp index d143c31..b45c563 100755 --- a/volume/key-manager.cpp +++ b/volume/key-manager.cpp @@ -86,7 +86,7 @@ void KeyManager::removeKey(const std::string& keyName) { const std::string ckmAlias = addAliasPrefix(keyName); - if (::ckmc_remove_data(ckmAlias.c_str()) != 0) { + if (::ckmc_remove_alias(ckmAlias.c_str()) != 0) { throw runtime::Exception("Failed to remove key data"); } } -- 2.7.4 From 02781665b94915d7b752350325f53c0f41426bd2 Mon Sep 17 00:00:00 2001 From: Sungbae Yoo Date: Mon, 22 Aug 2016 13:41:11 +0900 Subject: [PATCH 07/16] Remove installing /etc/pam.d/systemd-user Change-Id: I384028a4dd6d2a979fbfccf38c3dc81007db4dd6 Signed-off-by: Sungbae Yoo --- packaging/krate.spec | 2 -- 1 file changed, 2 deletions(-) diff --git a/packaging/krate.spec b/packaging/krate.spec index e132b27..2ee7289 100644 --- a/packaging/krate.spec +++ b/packaging/krate.spec @@ -82,8 +82,6 @@ mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants ln -s ../krate.service %{buildroot}/%{_unitdir}/multi-user.target.wants/krate.service %post -mv /etc/pam.d/systemd-user /etc/pam.d/systemd-user.keep -cp /etc/pam.d/systemd-user-krate /etc/pam.d/systemd-user %clean rm -rf %{buildroot} -- 2.7.4 From eb4e45e5f16ce0cb778a6b6bbfe3343e695a1a33 Mon Sep 17 00:00:00 2001 From: "seolheui,kim" Date: Fri, 26 Aug 2016 09:35:06 +0900 Subject: [PATCH 08/16] Fix warning of krate applications Change-Id: Ie8d51b4efd9752147e493baa0366b5be76dfd540 Signed-off-by: seolheui,kim --- tools/apps/kaskit/res/edje/app_icon.edc | 1 + tools/apps/kaskit/res/images/app_press_117.png | Bin 3104 -> 1998 bytes tools/apps/kaskit/res/images/btn_delete_nor.png | Bin 3701 -> 3289 bytes tools/apps/kaskit/res/images/btn_delete_press.png | Bin 3742 -> 3267 bytes tools/apps/kaskit/res/images/core_check_bg.png | Bin 1128 -> 419 bytes .../kaskit/res/images/core_check_bg_stroke.png | Bin 1141 -> 427 bytes tools/apps/kaskit/res/images/core_check_icon.png | Bin 1325 -> 605 bytes tools/apps/kaskit/res/images/default_app_icon.png | Bin 12850 -> 15273 bytes tools/apps/kaskit/res/images/folder_appicon_bg.png | Bin 6266 -> 6730 bytes .../kaskit/res/images/icon_badge_container.png | Bin 883 -> 957 bytes tools/apps/kaskit/res/images/popup_bg.png | Bin 1261 -> 559 bytes tools/apps/kaskit/res/images/sub_badge.png | Bin 6199 -> 3761 bytes tools/apps/keyguard/res/images/icon.png | Bin 23271 -> 21496 bytes tools/apps/keyguard/res/images/theme_bg.png | Bin 1311561 -> 1313962 bytes tools/apps/setup-wizard/res/images/icon.png | Bin 57662 -> 16736 bytes tools/apps/setup-wizard/res/images/theme_bg.png | Bin 6894 -> 5302 bytes 16 files changed, 1 insertion(+) diff --git a/tools/apps/kaskit/res/edje/app_icon.edc b/tools/apps/kaskit/res/edje/app_icon.edc index 9189df4..3af232f 100644 --- a/tools/apps/kaskit/res/edje/app_icon.edc +++ b/tools/apps/kaskit/res/edje/app_icon.edc @@ -156,6 +156,7 @@ group { name: "icon"; text_class: "ATO002"; min: 1 1; max: 1 1; + ellipsis: -1; } } description { diff --git a/tools/apps/kaskit/res/images/app_press_117.png b/tools/apps/kaskit/res/images/app_press_117.png index 5acae9d0ff39341450f2e0959cc91e8984ce0f35..75266daf31d4d4514dd58f351ea411524fb3ef63 100644 GIT binary patch delta 1960 zcmV;Z2Uqx@7|sun8Gi%-007zzW;Xx;00d`2O+f$vv5yP0Dy!50Qvv`0D$NK0Cg|`0P0`>06Lfe02gqax=}m;0007FOGiWi z|A&vvzW@LL32;bRa{vGUNB{r;NB~C3Yd!z~2BJwsK~#9!?SGx?R^zx5Mz_kc9Va1h zI?(g}uQyHT1`-n6vUGmP&W+qVfGy@@Efxe~ys1*DT)HVfLaP3ViHXr9#AqS}g+fp` zDlA~Bs3<8gl$4aX`r`v`>iUXENlDP?8qj~1<-Y*HE}<+Hrv7X&6y)SoZAMjSGzlp^ zGE!m$miBRb-+#6Km8B$S&Vrl*gSno4uZ60J=rdqIMpU~gsI?n)2j08-%F)=nV$O^i zZ&cU8y$))h8+!EWHc8#qF1tYmwUZl43KlGQ-fA2*w;R?PUrD+TuRQB!Uikr5MdU4Lu7zefdBl+1bInf$WLL>Ij) z=9VAaaYORKm|hNtkdP9SAa$So;iy87J07?r<|AD85HQ3HNCAsI_ivwzD%|qG4>IHv zAy-leF&Qb2;yl>%P*cW?8Ii!{;o&dk5MmM%BFs5C)#<2;K0kP%k2>FZt_xGHlRR z?z(&?6&)DT*@ej8|pODO7 z4>l$u-v_%7HDSz{xb?2PE=NR+-B*I!jVg?}C;94ozd%BQWxmT3qn*D#V$7hWJ?Syj z2-zKrccJ$9$;}r%q+LTX!u;l()x3y5Htmg z!+)qLV{SW;G#rvch^Sa>M&eCW;YVFF>b_(<5^n~dgb{tZ?7UtM=+}jzov4~2y$(m- zO$j}Q=+z7B4xDjMzr~Mh=SrbitkT4F8)gjAop;_w4$Y8k^+JQH=rcqIWK&;g8QOZV;ttgtPL;zEGw{8u)Z|$}-OMJeCi5OE_<2T`4Jmg+HJ_kJ>2<6uD3(eln*J2M*f6#(n1*``nz!3FsyRuu`VaCS&amWx5cmO}Z}FX2ml zGY1Ym`ZjX%#dCW<4HPQ@)(Ll`x^L#dA&t}Qlg0WqE1^eWg{2bAH?gW|P(!w>YEaAT zum5eKDoQzTSx#qFVT6JzX!iwBRDTpgi6Q*9YAA*B*h+=~WGN|y3KKZ2rNmGPP>|z- zbzy}grvSl`GY=efPVUqFoJHWM3y%ubM{Fa~BGr7pFj_Fj1Zh`=VNL-Js$oVMVC_($ zD4F>s3m&y%=E(z8!OS;Lk7}8}U%?QBEID&e)(m18-dGS;f~bH6Z_SFE)qi-+lo>9l z@f*Q0W4ij*%kjqanj1N_Kn}x{w}xrmigTs`bvX*dl=L}2pM4hv%0&<>s+SO(5o?qxF5VFqADHRM8CcAgm+BcQ5qC%5&XsV?`Fg)|Py~g|) zs^9T5?#%Krg~Ia8zx#J5J!G{KizewrA1hd1c-+j7PDgEE)7HZZj(=As+xgKssE!g_ zZ+_WUDFnxqM_vw>c#nl0OHsqNRSKB$i$BL|*~cTSqr}kG<5Vd@Qc^e$_c02sU)Xr&4as70Uw#{%69)26-o-KdWG3n zJ_-mz#gqxZ_hm+Zi+>6gb1GE5SJhWY)g!_$On5qP8}oAmjjKoP^!n~7pDM>2k4%`I zTktzSraBA-1%~KTS6(S1d~xiFXY%tK&}Fx3S&-MK9LR@1*ZKoQ{QmpDd18850r$Us z_fOV0IZa`uZ*fM(>N?-#GykM|7T!B#<5T^0laDcIX# z38Fb*^_7+sef`%~+!almdDbpGBHNo6MCJe>43+H#fbE%NAAkUmsUgQZ0TU2t4TR?8 z!gIkLL{r#ID0vkF4QBd_*dUOJd9Xj3!T@++FTjV!GKI|4H$lKOswsqo#KCd?R)8qr9Dx8E8bT2UNJB%!Ua%e@hq5_7Fa!#PTGi0g(-k3fxgjhbIars)-TFfT3vekM znm>=mW`S1~$zJRLo+(6>=|5Ls`u~(=ale;IR4`aD*&l|0!dI{K1Bk=@e<+jr6V2rj zfPeG-pTbB@2#t${Lxk%fXriaoY-u?A63NrvUzN-FWVn%MKlEO zBGFh>b`W>>H#`o9wr6p9WEKUm$C^S!3Q!u2iiYn)?L&#`i!n07A`sRFC~E}V#?lfa z8hTh!;eT+kY)SwVVDWx%ssD2If5~070@Gg<84GY|fdJKp!)AiNT^UXLbuRE<>V4-@ zf1L~Bmt2@A8Q5xL|EtkIjzsQRUH-JKX!Fzf088X{j>y*6KZgJykaU_o7UL8woX%F@ z_8(mTyHV{ni=$PpWiLK`4NP{`J@w(jd6VDf#=H|%#J7z@r+Y`#%DnD)d|ZHrDSh6G z0ouH%-msIzsh1;oeDOPf}PNbbURyxm`M~A!kg)=-LW!<&hvKv0as| z8j4~v=biELMrCeu0>MQ!hSrrx(##%Zbzky2BTDQWwP(I@A5|2(F<{MT75J;Hs^*3L zAehS3_)?WH@aE>*YFob?K}tlT7%pBWG{B}_jq9H+B;fW!bi?YWeSV)6QKvHT7i-AFbQ$L;|h2wcvbR)?i3&R*j%Ufg#IS)Kf#%< zpElCvd#WvF#`ROzMNml-C>5o!b8iF}w89jTvB`Ji0-wIPPf)bb)ayZvbXi~@mS<51 z#PA=pa>#V6I!zfY9;tljLn%(cwA28DLM^aa@kI-Ktj&EHo3h47)$_ck@t&`*UEsSF z*hSqRLge50ZPH*6L|!KO`u20jLZ*JRhD`PGp{|*y%^7=74_{JMDTmCvF|S(I$uu1uN14%Evrr!QFzcU+C!IE{S{>N1P~ad#dVg3g#JzZ{%I4sx zl!UMtB4~{N=v3DMdKJCorjY)Oy#1})?LheN3XWiU# zxkrbIyA4g^4Qz0g=9mGGc4?V~O|